GraphQL
GraphQL is a query language and runtime for APIs, developed by Facebook in 2012 and open-sourced in 2015. It provides a complete, understandable description of the data in your API and gives clients the power to ask for exactly what they need.
Unlike REST where each endpoint returns a fixed data structure, GraphQL has a single endpoint where clients send queries specifying the exact fields they want. This eliminates over-fetching (getting unnecessary data) and under-fetching (needing multiple requests).
A GraphQL schema defines types and their relationships using a Schema Definition Language (SDL). Resolvers are functions that fetch data for each field. Queries read data, mutations modify data, and subscriptions provide real-time updates via WebSockets.
Popular GraphQL tools include Apollo (client and server), Hasura (instant GraphQL API from databases), and Relay (Facebook's GraphQL client). GraphQL works well for complex UIs with nested data requirements, mobile apps (bandwidth efficiency), and API aggregation layers.
Want to learn more?
Explore more developer terms or read in-depth articles on the blog.
Browse all terms