GraphQL
A query language for APIs and a runtime for executing those queries by using a type system you define for your data.
Last updated
A query language for APIs and a runtime for executing those queries by using a type system you define for your data.
GraphQL is a query language for APIs and a server-side runtime for executing queries against a type system defined for your data. Developed by Facebook in 2012 and open-sourced in 2015, GraphQL allows clients to request exactly the data they need, avoiding the over-fetching and under-fetching problems common with REST APIs.
A GraphQL API exposes a single endpoint and uses a schema to define available types, queries (reads), mutations (writes), and subscriptions (real-time updates). Clients send queries specifying the exact fields and relationships they need, and the server returns a JSON response matching that structure. This reduces the number of network round trips required to fetch related data.
API gateways can sit in front of GraphQL APIs to provide authentication, rate limiting, and caching. However, caching GraphQL is more complex than caching REST because queries are typically sent as POST requests with varying bodies. Some gateways also support GraphQL-to-REST translation, allowing teams to expose a GraphQL interface while routing to existing REST backend services.
Last updated