GraphQL is a query language and runtime where clients specify exactly the data they need. Single endpoint, strongly typed schema, no over/under-fetching. Queries (read), Mutations (write), Subscriptions (real-time). The N+1 problem: resolving a list of N users then N separate DB queries for each user's posts. DataLoader solves this by batching and caching. Schema federation (Apollo Federation, GraphQL Mesh) composes schemas from multiple services.
Each stage in order — click any step to read what it does.
N+1 query problem and DataLoader solution.
The trade-offs worth knowing before you build this.
Every resolver returning a list of items where sub-fields require additional queries MUST use DataLoader. Without it, a query for 100 users with their posts fires 101 DB queries. With DataLoader: 2.
The SDL schema is the source of truth for what the API can do. Use Schema-first development: design the schema, generate types, then implement resolvers. Type-safe everywhere.
Persisted queries prevent arbitrary query execution (security) and reduce request size from thousands of characters to a short hash. Required for production mobile apps.
Sign in to share your feedback and join the discussion.