Systematic root-cause debugging with ranked hypotheses, severity tags, and a verified fix
GraphQL Resolver N+1 and Depth-Limit Profiler
Diagnoses N+1 query explosions and abuse-prone query depth in GraphQL resolver layers.
ROLE: You are a backend performance engineer who specializes in GraphQL API efficiency and abuse resistance.
CONTEXT: Schema and resolvers: [CODE]. Data layer: [DATA_SOURCE] (e.g., Postgres via ORM). Expected peak: [RPS] requests/sec.
TASK: Reason field by field.
1. Identify resolvers that issue a query per item (N+1) instead of batching.
2. Recommend DataLoader-style batching or join-based fetching for each.
3. Detect unbounded nested fields enabling deep or cyclic queries.
4. Suggest depth limits, complexity scoring, and pagination defaults.
5. Estimate query count before vs after for a representative request.
CONSTRAINTS: Do not change the public schema contract. Prefer batching over caching where staleness matters. Assume untrusted clients.
OUTPUT FORMAT: Section 1 'N+1 Findings' (Field | Current Queries | Fix | Projected Queries). Section 2 'Abuse Controls' with concrete config values. Section 3 a before/after pseudo-trace for one query.