GraphQL is an API standard and query language that lets consumers request or update specific data through a typed schema. Unlike REST endpoints with fixed response structures, a GraphQL query describes the desired response shape, allowing one endpoint to serve multiple purposes. section 3.8.1 section 7.1
A GraphQL application separates the contract from the data-fetching behavior:
- The GraphQL schema definition language (SDL) declares the fields and types consumers may query. section 7.1
- Resolvers define how the API obtains each requested value, such as retrieving a movie by identifier. section 7.1
- Queries that request fields absent from the SDL fail, making the schema an explicit consumer contract. section 7.1
Movie landing page
A movie landing page may need the movie, its actors, and other movies featuring those actors. REST may require several GET requests and return unused data; GraphQL can retrieve the requested structure with one query. Apollo Server can expose the GraphQL layer, while Apollo Client consumes it from a JavaScript frontend. section 7.1 section 7.2
Figure 7.2 A web consumer making a single query to a GraphQL endpoint to retrieve all the data they require
Shows a web consumer making one GraphQL query to retrieve the data it needs, contrasting with multiple REST requests. section 7.1





