WunderGraph
Read post

Understanding the N+1 Problem in GraphQL (and Why It’s Not Just GraphQL)

The N+1 problem — one query for a list plus one query per item — is a general data-access anti-pattern that appears in REST, monolithic GraphQL, and federated GraphQL, not just GraphQL. In resolver-based GraphQL, the default execution model makes it easy to introduce accidentally because sibling resolvers don't coordinate fetches. In federated GraphQL, router-level batching (e.g., WunderGraph's breadth-first loading) can reduce cross-subgraph fan-out, but subgraphs can still reintroduce N+1 if their `__resolveReference` resolvers fetch one record at a time. DataLoader is the most common fix — batching `.load()` calls within a scheduling window — but joins, ORM eager loading, denormalized views, or set-based SQL queries are often better for predictable access patterns. Detection requires correlating a GraphQL operation with backend call counts via database logs, distributed traces, or APM tools, since router traces may look fine while per-entity fan-out hides inside subgraphs.

    #graphql
Jul 22•13m read time•From wundergraph.com
Post cover image
Table of contents
What the N+1 Problem IsA Concrete N+1 Example in Monolithic GraphQLThe N+1 Problem in GraphQL FederationWhy the N+1 Problem Actually HurtsWhy N+1 Is Not Unique to GraphQLDataLoader Rules That Matter in PracticeAlternatives and Complements to DataLoaderDetecting N+1 in PracticeThe Practical TakeawayReferencesFrequently Asked Questions (FAQ)
277 Impressions
WunderGraph's image
WunderGraph

Wundergraph is a blog or publication focused on GraphQL, a query language and runtime for APIs. Thro...

34 Followers

•

437 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard