GraphQL
GraphQL is a query language for APIs and a runtime for answering those queries. The client describes exactly which fields it needs, and the server returns data in the same shape, usually through a single endpoint. GraphQL was created at Facebook in 2012, published as an open specification in 2015 and has been developed by the GraphQL Foundation since 2018; the latest edition of the specification was released in September 2025.
Key facts
| Type | Query language for APIs and a server runtime |
| Created | 2012 at Facebook; open specification published in 2015 |
| Maintainer | GraphQL Foundation, part of the Linux Foundation (since 2018) |
| Latest specification | September 2025 edition, the first since October 2021 |
| Operations | Queries (read), mutations (change), subscriptions (real-time updates) |
| Transport | Usually HTTP POST to a single endpoint such as /graphql, JSON responses |
| Reference implementation | graphql-js (JavaScript) |
| Used by | GitHub, Shopify, Linear, Meta and many others |
| Website | graphql.org |
What is GraphQL?
GraphQL is a way of building an API in which the client, not the server, decides what data comes back. In a typical REST API each URL returns a fixed set of fields, so an app often loads too much data or makes several requests to collect what one screen needs. In GraphQL the app sends one query listing the exact fields, including related objects, and gets exactly that.
Every GraphQL API is described by a schema: a typed list of objects, their fields and the operations clients can call. The schema doubles as documentation, and tools can use it to check queries and autocomplete them.
How does a GraphQL query work?
The server publishes a schema written in the GraphQL schema language:
type Query {
user(login: String!): User
}
type User {
name: String
repositories(first: Int): [Repository!]!
}
type Repository {
name: String!
stars: Int!
}
The client asks only for the fields it needs:
query {
user(login: "aidana") {
name
repositories(first: 2) {
name
stars
}
}
}
And the response has the same shape as the query:
{
"data": {
"user": {
"name": "Aidana",
"repositories": [
{ "name": "notes-app", "stars": 12 },
{ "name": "weather-bot", "stars": 5 }
]
}
}
}
On the server, each field is backed by a function called a resolver, which fetches the value from a database or another service.
How do you send a GraphQL request?
A GraphQL request is usually an HTTP POST with the query in a JSON body. For example, a request to GitHub's GraphQL API that returns the login of the token's owner:
curl https://api.github.com/graphql \
-H "Authorization: bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query": "query { viewer { login } }"}'
Variables are passed separately from the query text in a variables field, which keeps queries reusable and avoids building strings by hand.
How is GraphQL different from REST?
| GraphQL | REST | |
|---|---|---|
| Endpoints | One endpoint for all queries | Many URLs, one per resource |
| Shape of the response | Chosen by the client | Fixed by the server |
| Related data | One query can fetch nested objects | Often several requests |
| Typing | Strongly typed schema is required | Optional, for example via OpenAPI |
| Caching | Harder, because most queries are POST to one URL | Standard HTTP caching by URL |
| Errors | Usually HTTP 200 with an errors array |
HTTP status codes |
| Versioning | Fields are added and deprecated, without new versions | Often /v1, /v2 or dated versions |
REST is simpler for public APIs with predictable resources, such as the Stripe API. GraphQL is useful when many clients — web, mobile, partners — need different combinations of the same data. GitHub, Shopify and Linear offer GraphQL APIs, and Supabase can expose a Postgres database through GraphQL automatically.
What's new in the September 2025 specification?
The September 2025 edition, announced on September 8, 2025, is the first new edition of the specification since October 2021 and collects more than four years of changes. Its best-known addition is OneOf input objects: an input type in which the client must provide exactly one of several fields, which lets APIs accept "either this or that" without workarounds. Incremental delivery with @defer and @stream was not included and remains a proposal.
What are the downsides of GraphQL?
- The N+1 problem — naive resolvers can send a database query for every item in a list; libraries such as DataLoader batch these requests.
- Expensive queries — clients can request deeply nested data, so servers limit query depth and complexity.
- Caching — HTTP and CDN caching do not work out of the box; clients like Apollo and Relay cache by object instead.
- Extra infrastructure — a schema, resolvers and tooling are more work than a few REST endpoints for a small API.
Popular tools include Apollo Server and Apollo Client, GraphQL Yoga, Relay, and the GraphiQL in-browser editor for exploring an API.
Sources
- Learn GraphQL — GraphQL Foundation (accessed 1 December 2026)
- GraphQL Specification, September 2025 Edition — GraphQL Foundation (accessed 1 December 2026)
- Announcing the September 2025 Edition of the GraphQL Specification — GraphQL Foundation (accessed 1 December 2026)
- GitHub GraphQL API documentation — GitHub (accessed 1 December 2026)
- GraphQL — Wikipedia (accessed 1 December 2026)