A fork of graphql-depth-limit rebuilt for ESM and CJS with TypeScript declarations. Provides a dead-simple validation rule to limit the total depth of GraphQL queries, protecting against cyclical or deeply nested queries that could cause denial-of-service. Current stable version 1.1.1. Unlike cost-based libraries (graphql-query-complexity, graphql-validation-complexity), this library focuses solely on depth because complexity often increases exponentially with depth (e.g., SQL JOINs). Ships both ESM and CJS bundles with type definitions.
npm install graphql-depth-limit-tsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic setup with Express and express-graphql, limiting query depth to 10.
Combine with cost analysis libraries (e.g., graphql-query-complexity) for full protection.
Use graphql-depth-limit-ts instead, which supports ESM, CJS, and TypeScript types.
Review fragment expansions; consider depth limiting on resolver level as a complement.
Apply depthLimit() individually for each operation if using batched queries.
Run 'npm install graphql-depth-limit-ts' and import the correct package name.
Use 'import depthLimit from ...' (ESM) or 'const depthLimit = require(...).default' (CJS).
Use depthLimit() as a validation rule only; do not add schema directives.