GraphQL — a query language for APIs + runtime, built by Facebook (2015). A single endpoint /graphql, clients specify which fields to return — no over-fetching / under-fetching like REST. Typed schema. Pros: exact data shape, versionless API. Cons: harder caching (single endpoint), N+1 queries without DataLoader.
Below: details, example, related terms, FAQ.
query GetUser($id: ID!) {
user(id: $id) {
name
email
posts(first: 10) {
title
}
}
}GraphQL is faster for complex UIs (fewer round-trips). REST — for simple CRUD (better caching).
DataLoader (Facebook): batching + caching per-request. Or persistent queries + query whitelisting.
Yes. REST — HTTP cache by URL. GraphQL — application-level cache by query needed. Apollo Client handles this out of the box.