Bolt api

GraphQL Query Too Deep - Nested Query Recursion Attack

GraphQL queries with deep nesting cause timeouts or excessive server load. User can request deeply nested data causing exponential database queries.

Server becomes unresponsive to legitimate queries.

Error Messages You Might See

Query exceeds maximum depth Query too complex - execution timeout Maximum query cost exceeded Recursion depth exceeded
Query exceeds maximum depthQuery too complex - execution timeoutMaximum query cost exceededRecursion depth exceeded

Common Causes

  1. No query depth limit - unlimited nesting allowed
  2. No complexity calculation
  3. Circular references in schema allowing infinite recursion
  4. No timeout on query execution
  5. Database N+1 problem triggered by deep nesting

How to Fix It

Add depth limit: graphql-depth-limit middleware, max depth 7

Add complexity limit: estimate cost per field, reject if over budget

Break circular references: use aliases or limit nesting depth

Set query timeout: 10-30 seconds max execution time

Use data loader to prevent N+1 queries

Real developers can help you.

Mehdi Ben Haddou Mehdi Ben Haddou - Founder of Chessigma (1M+ users) & many small projects - ex Founding Engineer @Uplane (YC F25) - ex Software Engineer @Amazon and @Booking.com rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) PawelPloszaj PawelPloszaj I'm fronted developer with 10+ years of experience with big projects. I have small backend background too Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. hanson1014 hanson1014 Full-stack developer experienced in fixing and deploying AI-generated apps from Lovable, Bolt.new, Cursor, and Replit. I specialize in debugging Supabase integration issues (auth flows, RLS policies, database connections), fixing broken deployments, resolving routing/blank screen problems, and cleaning up messy React/Vite codebases. I also build production apps with the Claude API and have shipped a Mac desktop dev tool (Nexterm from scratch. Based in Hong Kong, fast turnaround. Matt Butler Matt Butler Software Engineer @ AWS MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. Nam Tran Nam Tran 10 years as fullstack developer

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

What's a reasonable query depth limit?

7-10 is good balance. Most legitimate queries are 3-5 levels deep

How do I implement depth limit?

Use graphql-depth-limit package: depthLimit(10) as middleware

What's query complexity?

Estimate cost: simple field = 1, list = 10. Reject queries exceeding total budget (e.g., 1000)

Related Bolt Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help