GraphQL

/ɡræf kjuː ɛl/ · Noun · Development · Origin: 2015

Definitions

  1. GraphQL is a query language for APIs and a runtime for executing those queries against your data. Developed by Facebook in 2012 and open-sourced in 2015, it lets clients request exactly the data they need in a single request, eliminating the over-fetching and under-fetching problems common with REST APIs. A GraphQL API defines a strongly typed schema that describes available data types, queries, and mutations, serving as both documentation and a contract between client and server. Clients send queries that mirror the shape of the desired response, making the API intuitive and self-documenting. GraphQL also supports subscriptions for real-time data updates over WebSocket connections. It works with any backend language and data source, acting as a flexible layer between clients and services. Companies like GitHub, Shopify, and Yelp use GraphQL in production to power complex, data-rich applications where different clients need different subsets of the same data.

    In plain English: A way to ask a server for exactly the data you want in one request, instead of getting a bunch of stuff you don't need — like ordering only the dishes you want instead of getting a fixed menu.

  2. GraphQL's biggest criticism is the N+1 query problem: a naive implementation resolves each field independently, potentially making thousands of database queries for a single GraphQL request. DataLoader (batching and caching) and query complexity analysis are essential for production GraphQL.

    Example: 'Our GraphQL API was making 200 SQL queries per request. Adding DataLoader batching reduced it to 5. Without it, GraphQL will destroy your database.'

    Source: N+1 problem / criticism

Origin Story

Facebook's query language for APIs that let the client be the boss

**GraphQL** was created at Facebook in 2012 by **Lee Byron**, **Dan Schafer**, and **Nick Schrock**. The team was rebuilding Facebook's mobile apps and found REST APIs inadequate: each screen needed data from multiple endpoints, leading to either too many requests or overfetching (getting more data than needed).

GraphQL's key innovation was letting the client specify exactly what data it needed in a single query. Instead of multiple REST endpoints returning fixed data shapes, a single GraphQL endpoint accepted a query describing the desired fields and relationships. The server returned precisely that shape — no more, no less. Facebook used it internally for three years before open-sourcing it in 2015.

The name is a portmanteau of "Graph" (Facebook's social graph data model, where everything is connected) and "QL" (Query Language). Despite the SQL-like abbreviation, GraphQL queries look nothing like SQL — they resemble JSON with the values removed. The technology sparked an ongoing debate: GraphQL vs. REST, with proponents of each arguing about complexity, caching, and when each approach is appropriate.

Coined by: Lee Byron, Dan Schafer, Nick Schrock

Context: Facebook, 2012; open-sourced 2015

Fun fact: GraphQL was originally called 'SuperGraph' internally at Facebook. The rename happened before open-sourcing. Lee Byron has said the hardest part of creating GraphQL wasn't the technology — it was convincing Facebook's infrastructure team to let a single endpoint replace hundreds of REST endpoints.

Related Terms