DataLoader is a GraphQL performance pattern that batches related resolver requests into fewer backend queries. It addresses the N+1 problem, where one query loads a collection and each returned item triggers another query. section 5.3.3
Users and posts
A request for users and their posts should require two database queries. Without batching, one users query can be followed by a separate posts query for every user, producing dozens or hundreds of queries instead. section 5.3.3
Apply the pattern by:
- Identifying nested resolvers that issue repeated backend requests. section 5.3.3
- Implementing explicit request batching so individual resolver requests become fewer database queries. section 5.3.3
