What is the N+1 problem in GraphQL and how do you solve it?
spaceto flip
When a query returns N items and each item triggers a separate database call for a related field, you get 1 + N queries. Example: 20 posts each fetching their author = 21 queries. Solution: DataLoader. It batches all .load() calls in the current event loop tick into a single batch query (WHERE id IN (...)). Create DataLoader instances per request, not globally.