Cianplan

Level 1: Foundations · L1.1 APIs: REST, gRPC, GraphQL, WebSockets/SSE, webhooks

GraphQL: flexible queries and their cost

Explain GraphQL's benefits and its caching and N+1 problems.

12 min · Free

What you take away

  • One typed schema lets each client ask for exactly the fields it needs, collapsing a waterfall of REST calls into one request.
  • A cheap-looking query can fan out into hundreds of database queries — the N+1 problem — unless resolvers batch.
  • Everything goes to one endpoint, so URL-based HTTP and CDN caching stops working.
  • Cost moves to the server, so you need depth limits, cost analysis and persisted queries instead of counting requests.

How the class is laid out

  1. The problem
  2. The simple version
  3. Where the cost goes
  4. The caching problem
  5. Check your understanding