What is GraphQL
GraphQL is a query language for APIs, created by Facebook in 2012 and open-sourced in 2015. Instead of the server deciding what data to return (as in REST), the client describes exactly what fields it needs in a query, and the server returns exactly that — nothing more, nothing less.
How it works
A GraphQL API has a typed schema that defines all available types and their fields. Clients write queries against this schema. The server uses resolvers to fetch the data for each field. Everything goes through a single endpoint (POST /graphql), and the query in the request body determines what comes back.
GraphQL supports three operation types: queries (reads), mutations (writes), and subscriptions (real-time updates).
Why it matters
GraphQL eliminates two common REST problems. Over-fetching: a REST endpoint returns all fields even if you only need two. Under-fetching: getting related data requires multiple REST requests. GraphQL solves both — one request, exact fields. The tradeoff: no native HTTP caching, higher server complexity, and risk of expensive nested queries without proper safeguards.
See How GraphQL Works for schemas, resolvers, the N+1 problem, and when to choose GraphQL over REST.