GraphQL

GraphQL is an API query language and runtime in which clients request exactly the fields they want from a typed schema. A single endpoint accepts queries, mutations, and subscriptions, and the server resolves only the requested fields, often combining data from multiple underlying sources.

How it works

The server publishes a schema written in the GraphQL SDL, defining types, queries, mutations, and subscriptions. Clients send a query naming the operation, fields, and arguments. The server runs resolvers for each requested field and returns a JSON response shaped exactly like the query.

Key features include strong typing, introspection (the API documents itself), a single endpoint (no URL design needed), and the ability to coalesce many backends behind one schema.

Common implementations

  • Server: Apollo Server, GraphQL Yoga, Mercurius, graphql-go, gqlgen, Strawberry
  • Schema-first platforms: Hasura, PostGraphile, AWS AppSync, Grafbase
  • Client: Apollo Client, urql, Relay, graphql-request
  • Federation: Apollo Federation, Cosmo, Hot Chocolate, allowing multiple GraphQL services to expose one unified schema

GraphQL vs REST

  • REST models resources, exposes many URLs, leans on HTTP caching, simpler to reason about.
  • GraphQL models a graph of types, exposes one URL, gives clients flexible field selection, harder to cache, stronger fit when aggregating across multiple services.
🔗
Related Terms
REST API, HTTP, gRPC, JSON, API Gateway.

Subscribe to Sahil's Playbook

Clear thinking on product, engineering, and building at scale. No noise. One email when there's something worth sharing.
[email protected]
Subscribe
Mastodon