Skip to content
IT glossary
BackendUpdated December 3, 2026

GraphQL

With GraphQL, an API client asks for specific fields, such as a book’s title and its author’s name. The server checks the request against its schema and returns data in the shape the client requested.

What GraphQL is

GraphQL is a language for requesting data from an API, with rules for how the server executes those requests. The API's typed schema defines the fields clients can ask for, the arguments those fields accept, and the types they return. A search results page might need only book titles and author names, while a book details page also needs a description and publication year. Both can use the same schema and select different fields.

From request to response

GraphQL defines three operation types: queries read data, mutations change it, and subscriptions deliver updates over time. Before executing an operation, the server validates it against the schema. An unknown field, for example, causes validation to fail before any resolver runs. A resolver supplies a field's value. It might read a property from an object the server already fetched, query a database, or call another service. GraphQL doesn't prescribe a storage engine or replace SQL.

Example: fetching a book card

query BookCard($id: ID!) {
  book(id: $id) {
    title
    author {
      name
    }
  }
}

The client sends id separately in the variables object. The ID! declaration requires a non-null ID. In a successful response, data.book contains title and an author object containing name; unrequested fields such as description are left out. If a resolver fails during execution, the response can contain both partial data and an errors array. An error on a non-null field propagates to the nearest nullable parent; if there isn't one, data becomes null.

When it helps and what it costs

GraphQL is useful when several clients need different views of the same data or when a screen draws from multiple backend services. Queries and mutations often travel over HTTP to a single endpoint, but one client request can still trigger many backend calls. For example, after fetching a list of books, a naïve author resolver may fetch one author per book. This is the N+1 problem. Batching author lookups or fetching books and authors together can remove the extra calls.

What to cover in an interview

Compare GraphQL and REST using a real screen rather than claiming one is always faster. Selecting fields can reduce the response size and the number of client round trips, but server cost depends on how those fields are resolved. Be ready to explain how you'd limit expensive operations and enforce authorization: a field being present in the schema doesn't mean every caller is allowed to see its value.