ZuploZuplo
LoginSign Up
  • Documentation
  • API Reference
Introduction
Getting Started
    Develop using the Portal
      1 - Setup Your Gateway2 - Rate Limiting3 - API Key Auth4 - Deploy5 - Dynamic Rate LimitingMCP - Quick start
    Develop Locally
      1 - Setup Your Gateway2 - Rate Limiting3 - API Key Auth
Concepts
Development
Policies
    Policy Catalog
    Authentication
    Authorization
    Security & Validation
    Metrics, Billing & Quotas
    Testing
    Request Modification
    Response Modification
    Upstream Authentication
    Archival
    GraphQL
      GraphQL Disable Introspection PolicyGraphQL Introspection Filter PolicyGraphQL Complexity Limit Policy
    Other
    Guides
Handlers
API Keys
MCP Server
MCP Gateway
AI Gateway
Developer Portal
Monetization
Deploying & Source Control
Observability
Networking & Infrastructure
Account Management
Programming API
Build with AI
Zuplo CLI
Migration Guides
Platform LimitsSecuritySupportTrust & ComplianceChangelog
powered by Zudoku
GraphQL

GraphQL Complexity Limit Policy

This policy allows you to add a limit for the depth and a limit for the complexity of a GraphQL query.

Configuration

The configuration shows how to configure the policy in the 'policies.json' document.

config/policies.json
{ "name": "my-graphql-complexity-limit-inbound-policy", "policyType": "graphql-complexity-limit-inbound", "handler": { "export": "GraphQLComplexityLimitInboundPolicy", "module": "$import(@zuplo/graphql)", "options": { "useComplexityLimit": { "complexityLimit": 10 }, "useDepthLimit": { "ignore": [] } } } }

Policy Configuration

  • name <string> - The name of your policy instance. This is used as a reference in your routes.
  • policyType <string> - The identifier of the policy. This is used by the Zuplo UI. Value should be graphql-complexity-limit-inbound.
  • handler.export <string> - The name of the exported type. Value should be GraphQLComplexityLimitInboundPolicy.
  • handler.module <string> - The module containing the policy. Value should be $import(@zuplo/graphql).
  • handler.options <object> - The options for this policy. See Policy Options below.

Policy Options

The options for this policy are specified below. All properties are optional unless specifically marked as required.

  • useComplexityLimit (required) <object> - No description available.
    • complexityLimit <number> - The maximum complexity a query is allowed to have.
    • endpointUrl <string> - The endpoint URL to use for the complexity calculation.
  • useDepthLimit (required) <object> - No description available.
    • depthLimit <number> - The maximum depth a query is allowed to have.
    • ignore <string[]> - The fields to ignore when calculating the depth of a query.

Using the Policy

Depth Limit

Limit the depth a GraphQL query is allowed to query for.

  • maxDepth - Number of levels a GraphQL query is allowed to query for.

This allows you to limit the depth of a GraphQL query. This is useful to prevent DoS attacks on your GraphQL server.

Code
{ # Level 0 me { # Level 1 name friends { # Level 2 name friends { # Level 3 name # ... } } } }

Complexity Limit

Example:

  • maxComplexity - Maximum complexity allowed for a query.
Code
{ me { name # Complexity +1 age # Complexity +1 email # Complexity +1 friends { name # Complexity +1 height # Complexity +1 } } } # Total complexity = 5

Read more about how policies work

Edit this page
Last modified on May 29, 2026
GraphQL Introspection Filter PolicyComposite Inbound (Group Policies) Policy
On this page
  • Configuration
    • Policy Configuration
    • Policy Options
  • Using the Policy
    • Depth Limit
    • Complexity Limit
JSON