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.

zipking zipking I am a technologist and product builder dedicated to creating high-impact solutions at the intersection of AI and specialized markets. Currently, I am focused on PropScan (EstateGuard), an AI-driven SaaS platform tailored for the Japanese real estate industry, and exploring the potential of Archify. As an INFJ-T, I approach development with a "systems-thinking" mindset—balancing technical precision with a deep understanding of user needs. I particularly enjoy the challenge of architecting Vertical AI SaaS and optimizing Small Language Models (SLMs) to solve specific, real-world business problems. Whether I'm in a CTO-level leadership role or hands-on with the code, I thrive on building tools that turn complex data into actionable value. BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. Rudra Bhikadiya Rudra Bhikadiya I build and fix web apps across Next.js, Node.js, and DBs. Comfortable jumping into messy code, broken APIs, and mysterious bugs. If your project works in theory but not in reality, I help close that gap. Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. legrab legrab I'll fill this later Matt Butler Matt Butler Software Engineer @ AWS Bastien Labelle Bastien Labelle Full stack dev w/ 20+ years of experience Victor Denisov Victor Denisov Developer Tejas Chokhawala Tejas Chokhawala Full-stack engineer with 5 years experience building production web apps using React, Next.js and TypeScript. Focused on performance, clean architecture and shipping fast. Experienced with Supabase/Postgres backends, Stripe billing, and building AI-assisted developer tools.

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