GraphQL is a query language and server-side runtime for APIs that lets clients specify exactly which fields they need in a single request, rather than being handed a fixed response shape by the server. It was created at Facebook in 2012, open-sourced in 2015, and is now maintained by the GraphQL Foundation under the Linux Foundation, with its specification published at spec.graphql.org.
A GraphQL API exposes a single endpoint backed by a strongly typed schema, written in Schema Definition Language (SDL), that declares every object type and the fields it has. Clients send a query shaped like the response they want:
type Book {
title: String!
author: String!
}
query {
book(id: "1") {
title
}
}
The server resolves each field independently via a resolver function, so a query nesting author { books { title } } fans out to multiple resolver calls but returns as one JSON response, shaped exactly like the query. The schema defines three root operation types: Query (read), Mutation (write), and Subscription (real-time updates over a persistent connection).
GraphQL's main pitch over REST is avoiding over-fetching (getting a payload with fields you don't need) and under-fetching (needing several round-trips to assemble one view). A JSON payload that already looks like a nested object graph — the output of a tool like JSON to GraphQL — maps naturally onto a GraphQL schema, since both share the same tree-shaped data model.
errors array, not the status code.