What Is GraphQL? Read an API Request Through Its Schema and Operations
GraphQL is a query language for API requests and a server-side runtime that executes them against a type system the service defines. The schema describes which fields are available; a client selects fields from that contract, and the server validates the selection before resolving the requested data.
GraphQL is a query language for API requests and a server-side runtime that executes them against a type system the service defines. The schema describes which fields are available; a client selects fields from that contract, and the server validates the selection before resolving the requested data. GraphQL is not a database or a promise that one network request will always be faster or simpler.
This article uses the September 2026 GraphQL specification and official GraphQL learning materials to explain how a schema-guided request becomes a response. Framework setup and any specific GraphQL transport protocol are out of scope.
What does a GraphQL schema tell you?
A schema describes the types, fields, inputs, and relationships that a GraphQL service exposes. For example, if a Product type has name and price fields and a product field on Query looks up a product, a client can request fields in that contract.
type Query {
product(id: ID!): Product
}
type Product {
id: ID!
name: String!
price: Int!
reviews(first: Int = 3): [Review!]!
}
type Review {
rating: Int!
body: String!
author: User!
}
type User {
name: String!
}This schema is illustrative; it does not claim to describe a real service or storage model. String, Int, and ID are built-in scalar types. ! means a value cannot be null. [Review!]! means a non-null list whose entries are also non-null. Type information helps identify invalid fields or inputs before execution and lets client tools anticipate the response shape.
A schema is not the same as a database schema. A GraphQL server can connect each field to an existing database, another service, a computed function, or composition logic. The function that supplies a field is commonly called a resolver. For example, the product resolver may look up a product and the reviews resolver may fetch its reviews. The data actually retrieved depends on the server implementation and its authorization rules.
What data does a query fetch?
A query is a read operation. The client starts at a root field and selects the fields it needs at each nested level. In the example below, variables supply the product ID and number of reviews; the client asks only for the product name, price, review text, and author name.
query ProductCard($id: ID!, $reviewCount: Int = 3) {
product(id: $id) {
name
price
reviews(first: $reviewCount) {
rating
body
author {
name
}
}
}
}Variable values can be sent separately from the query document:
{
"id": "p-42",
"reviewCount": 2
}The service processes this example in stages:
It parses the GraphQL document to understand its structure.
It validates the fields and argument types, such as `product`, `name`, and `reviews`, against the schema. An unknown field generally causes an error before execution.
If the request is valid, the server runs field resolvers to obtain values from its data sources.
The `data` in the response reflects the requested selection. If a field fails during execution, an `errors` entry may accompany the response; depending on the field's nullability, some data may still be returned.
An illustrative response might look like this:
{
"data": {
"product": {
"name": "Notebook",
"price": 1200,
"reviews": [
{"rating": 5, "body": "Lightweight", "author": {"name": "Mina"}}
]
}
}
}The values are fictional. GraphQL shapes results to resemble the query selection, but it does not guarantee server processing time or the number of data-source calls. One nested field may cause several database calls, or the server may be implemented to batch work efficiently.
How do queries, mutations, and subscriptions differ?
A GraphQL schema must provide a query root type. Writing data through a mutation root type and receiving ongoing event updates through a subscription root type are optional capabilities.
| Operation | Purpose | Execution characteristics |
|---|---|---|
query | Read data | Resolving non-top-level fields must be side-effect-free and idempotent. Ordinary query fields may be executed in parallel. |
mutation | Change data | Top-level mutation fields may cause side effects and run serially within one mutation. This does not mean the work is a database transaction. |
subscription | Receive updates when events occur | A long-lived request. The GraphQL specification does not choose the transport; implementations commonly use WebSockets or Server-Sent Events. |
A mutation also lets the client select which fields to receive after the change. The client may request the new value in the same operation instead of making a separate follow-up query. However, serial execution of multiple top-level mutation fields is not an atomic transaction. If an earlier field succeeds and a later one fails, GraphQL does not automatically undo the earlier change.
Subscriptions can suit event updates that need to arrive close to real time, but they add connection lifecycle, reconnection, scaling, and authorization work. GraphQL itself does not require WebSockets; when data changes infrequently, periodic refetching may be simpler.
Does GraphQL always finish in one request?
No. Selecting related fields in one GraphQL operation can reduce round trips, but the service can expose only the capabilities defined by its schema. A subscription may require a long-lived connection, and large lists or data for different screens may need separate operations. GraphQL is often served from one HTTP endpoint, but that is a common deployment choice, not a requirement of the GraphQL language.
The flexibility of client-selected fields also creates server responsibilities. Deep or broad queries, large lists, and repeated field calls can trigger substantial work. If each resolver separately queries a database for every item, it can create the pattern commonly called the N+1 problem. A service needs to design page sizes, query depth and cost limits, request limits, batching of data loads, and caching. The server must also check authorization at the boundary of sensitive fields or actions, rather than relying only on the client’s screen.
Field-selected requests can also require deliberate design for HTTP caching and observability. Different query documents, variables, and selected fields can lead to different cache keys and performance profiles. Do not assume GraphQL is automatically cacheable or faster; measure actual request costs and response times.
How do you choose between REST and GraphQL?
They are different approaches to designing and exposing an API. REST is often organized around HTTP resources, methods, and cacheable responses. GraphQL is organized around a typed schema and field selections that let clients request a response shape. Neither approach is always better.
| Situation | What to consider |
|---|---|
| You want fixed resource contracts and standard HTTP caching | A resource-oriented REST design may be simpler. |
| Different clients need different combinations of nested data | A GraphQL schema can provide flexible field selection and response composition. |
| The team can operate schema, resolver, and query-cost controls | That is a foundation for running GraphQL reliably. |
| The API is small and simple, or mainly transfers files or streams | A GraphQL layer may add complexity; an HTTP API or dedicated protocol may be more direct. |
Start with client data needs, the cache and authorization model, and the operational work the team can support—not the API label. An existing REST API does not have to be replaced with GraphQL. GraphQL may be worth considering as a separate entry layer when a particular view needs to combine data from several sources.
Sources
[GraphQL Specification, September 2026 Edition](https://spec.graphql.org/September2026/)
[GraphQL.org: Introduction](https://graphql.org/learn/introduction/)
[GraphQL.org: Schemas and Types](https://graphql.org/learn/schema/)
[GraphQL.org: Queries](https://graphql.org/learn/queries/)
[GraphQL.org: Mutations](https://graphql.org/learn/mutations/)
[GraphQL.org: Subscriptions](https://graphql.org/learn/subscriptions/)
[GraphQL.org: Validation](https://graphql.org/learn/validation/)
[GraphQL.org: Execution](https://graphql.org/learn/execution/)
[GraphQL.org: Response](https://graphql.org/learn/response/)
[GraphQL.org: Performance](https://graphql.org/learn/performance/)
[GraphQL.org: Security](https://graphql.org/learn/security/)