Glossary · Definition
GraphQL
GraphQL is a typed query language for APIs. Clients send a query describing exactly which fields they want from related resources, the server resolves it, and the response shape matches the query. One endpoint, no over- or under-fetching.
Definition
GraphQL is a typed query language for APIs. Clients send a query describing exactly which fields they want from related resources, the server resolves it, and the response shape matches the query. One endpoint, no over- or under-fetching.
What it means
Originated at Facebook (2012, public 2015) for their mobile apps where REST roundtrips wasted bandwidth. The schema is the contract: types, fields, queries, mutations, subscriptions. Clients introspect the schema (typically via tooling like GraphiQL / Apollo Studio / GraphQL Codegen) and write queries. Each field has a resolver on the server side. Modern GraphQL servers: Apollo Server, GraphQL Yoga, Hasura (auto-generated from Postgres), PostGraphile (same), Hot Chocolate (.NET). Modern clients: Apollo Client, urql, Relay, react-query with graphql-request.
Advertisement
Why it matters
GraphQL solves real REST pain points (multiple roundtrips for related data, over-fetching, manual versioning) but introduces its own (caching is harder, server-side complexity, n+1 queries by default). Use it when: clients fetch many related resources in one screen (mobile apps, dashboards), the backend serves multiple frontends with different data needs, or you have a complex domain model and want strong typing client-to-server. Skip it when: you're a small team building a CRUD app (REST is simpler), you need HTTP cache friendliness (REST + HTTP/2 wins here), or you don't have someone who'll champion the schema design.
Frequently asked questions
GraphQL vs REST?
Different shapes, both valid. GraphQL: one endpoint, client-controlled response shape, typed schema. REST: many endpoints, server-defined response shape, conventions instead of types. Most modern shops do REST + OpenAPI for typed REST.
GraphQL vs tRPC?
tRPC is RPC-style with TypeScript end-to-end inference. No schema language; uses your TS types as the contract. Smaller, simpler, only works when both ends are TS. GraphQL works across any language and is better when you have many clients.
Is GraphQL slow?
Naive implementations have n+1 query problems (fetch users, then 1 query per user for posts). DataLoader pattern + persisted queries fix it. With proper batching, typical GraphQL is competitive with REST.
Related terms
- DefinitionAPIAn API (Application Programming Interface) is a contract that lets one program request something from another — typically over HTTP, in JSON. 'Web APIs', 'REST APIs', 'GraphQL APIs' are all flavors of the same idea: a defined surface for programmatic access.
- DefinitionRESTREST is an architectural style for HTTP APIs: each URL is a resource, HTTP verbs (GET, POST, PUT, PATCH, DELETE) operate on resources, responses are typically JSON. 'REST' colloquially means 'JSON HTTP API'; strict REST has more constraints most APIs ignore.