System Design
10. API Design and ManagementAnimated
GraphQL API Design
A typed schema where clients choose the fields.
The idea
Design the schema around the domain, use resolvers, and guard against expensive queries.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- current message
- earlier
- failure or attack
The client asks for exactly the fields it needs in one request.
- step:
- 1/6
- from:
- Client
- to:
- GraphQL server
1/6
Time runs downward. Solid arrows are requests, dashed arrows are replies.
Step by step
- 1Define types and queries
- 2Write resolvers
- 3Batch lookups with a loader
- 4Limit depth and cost
Where it is used
Complex client needs.
Watch out for
The N+1 query problem without batching.