awesome-everything RU
↑ Back to the climb

APIs

GraphQL N+1: multiple-choice review

Crux Multiple-choice synthesis across the GraphQL N+1 unit — resolver isolation, DataLoader scope, batch contracts, federation, and query-shape defences.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 13 min

Six questions that cut across the whole unit. Each one is a decision you make in a real review or incident — not a definition to recite, but a tradeoff to weigh when one HTTP request is quietly firing a thousand SQL queries.

Goal

Confirm you can connect resolver isolation, DataLoader batching and scope, batch-function contracts, federation, and query-shape defences — the synthesis the six lessons built toward.

Quiz

A REST controller serving the same posts-with-authors page issues one JOIN; the GraphQL server issues 51 queries. The schema has no bug. What is the structural cause?

Quiz

Why does DataLoader batch on the event-loop tick boundary rather than a fixed 5 ms timer, and what does that buy you?

Quiz

A refactor moved one DataLoader from the Apollo context factory into module scope. DB call rate is 6× normal at unchanged HTTP rate, and one tenant intermittently sees another tenant's rows. Why?

Quiz

A batchLoadFn runs SELECT ... WHERE id = ANY($1) and returns the rows in the order Postgres gave them. Intermittently, posts show the wrong author. What is the rule it broke?

Quiz

An Apollo Federation supergraph routes a query referencing 50 users across two subgraphs. What does the router handle, and what does the users subgraph still owe?

Quiz

DataLoader is live and the page is fast. An attacker sends one document with 1000 root aliases (q1: user(id:1)…q1000: user(id:1000)). DB trips collapse to one batch, yet the server still struggles. Why, and what stops it?

Recap

The unit’s through-line is one pipeline: resolver isolation creates N+1, DataLoader collapses the DB trips at the tick boundary but only with per-request scope and a correct same-order batch contract, federation hands you the network batch while you still owe the DB batch in __resolveReference, and query-shape defences (depth, multiplicative complexity, persisted/trusted documents, alias and batch caps) stop the attacks DataLoader cannot touch. DataLoader fixes how many DB trips a query makes; the defence layers govern what query shapes are even allowed to run.

Continue the climb ↑GraphQL N+1: free-recall review
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.