graphql-n-plus-one-remediationlisted
Install: claude install-skill testland/qa-skills
# graphql-n-plus-one-remediation
## What N+1 looks like in a resolver tree
One field returns a list of N rows. The executor then invokes the resolver
for each inner field once per row, so if `Query.topReviews` returns ten
reviews the executor resolves `Review.product` ten times, and a data-source
call in that child field becomes ten calls
([apollographql.com](https://www.apollographql.com/docs/graphos/schema-design/guides/handling-n-plus-one)).
So 1 outer query plus N inner queries equals N+1.
```typescript
// Parent resolver fetches N posts
posts: () => db.posts.findMany({ limit: 50 })
// Inner field-resolver fires once per post (50 DB calls)
Post: {
author: (post) => db.users.findOne({ where: { id: post.authorId } }),
}
```
GraphQL makes the pattern easy to hit because the resolver tree, not the
caller, decides how many times a child field runs.
Observable symptoms (practitioner heuristics, not standardised
thresholds):
- Tail latency on a list field grows roughly in proportion to the number
of rows the list returns.
- Database connection pool exhaustion under modest GraphQL request rates.
- A resolver-level trace shows the child field resolved once per parent
row rather than once per request.
## What this skill owns, and what it does not
Owned: locating the N+1 pattern inside a resolver tree and changing the
data-loading strategy so the child field costs one batched call instead
of N calls.
Not owned:
- **Query complexity or depth limiting.** Those reject