GraphQL is a query language and runtime for APIs, developed by Facebook and open-sourced in 2015, that allows clients to specify precisely the data they need in a single request rather than consuming fixed-shape REST endpoints. It is defined by a strongly typed schema that describes the graph of types and fields the API exposes, and a runtime that resolves client queries against that schema by executing resolver functions. GraphQL eliminates the over-fetching and under-fetching problems inherent in REST by shifting data shape control to the client, and its introspection capability enables rich developer tooling and automatic documentation generation.
Content
- GraphQL was developed internally at Facebook beginning in 2012 to solve a specific engineering problem: the existing REST APIs designed for web clients were ill-suited to the heterogeneous data requirements of the Facebook iOS and Android apps, which needed to fetch complex social graphs while minimising round trips over constrained mobile networks. The team built a query language that allowed the mobile app to specify precisely which fields of which objects to retrieve in a single request. After extensive internal use, Facebook open-sourced GraphQL in 2015 alongside a reference implementation in JavaScript, and formed the GraphQL Foundation (now under the Linux Foundation) in 2018 to govern further specification development.
- The GraphQL execution model defines three operation types: queries (read), mutations (write), and subscriptions (real-time event streams). The schema—written in the GraphQL Schema Definition Language (SDL)—declares every type, field, and their relationships, forming a self-describing contract that enables introspection: a GraphQL server can answer queries about its own schema, powering IDE autocompletion, documentation generators like GraphiQL, and client code generation tools. Each field in the schema maps to a resolver function responsible for fetching the required data from databases, microservices, or other sources. The DataLoader pattern is used to batch and cache downstream data fetches, solving the N+1 query problem where naive resolver implementations make one database call per list item.
- GraphQL adoption grew rapidly through major deployments at GitHub (2016), Twitter, Shopify, and Airbnb. The GitHub GraphQL API demonstrated the pattern of API versioning through schema evolution rather than URL versioning, and the richness of querying across interconnected resources such as repositories, pull requests, and users without separate endpoint calls. The Apollo Platform emerged as the leading commercial ecosystem around GraphQL, offering client libraries (Apollo Client for React, iOS, Android), server middleware, and federation tooling that became the de-facto standard for enterprise GraphQL deployments.
- In 2024-2025, GraphQL federation—the approach of composing a supergraph from multiple subgraph services—has become the standard architecture for platform-scale GraphQL deployments. Apollo Federation and Hive are competing platforms for managing federated schemas across dozens of service teams. GraphQL is increasingly used as the unified data access layer for AI applications: LLM agents use GraphQL APIs to query structured business data in a typed, introspectable way that is more amenable to code generation than free-form REST. Persisted queries and APQ (Automatic Persisted Queries) are standard performance optimisations, and edge-executed GraphQL via Cloudflare Workers and similar runtimes is reducing response latency for globally distributed clients.