GraphQL schema design and query limits

Relay connections, depth limits, and persisted queries under ADP-041.

Execution guards before running queries

Prevent nested list amplification on public or mobile GraphQL servers.

ControlThresholdAttack blockedRule
Query depth capMax 8 to 10 nesting levelsCyclic user.orders.user.orders recursionADP-041
Complexity cost budgetWeighted list multipliersProduct of nested first: 100 listsADP-041
Persisted queriesSHA-256 operation allowlistUnbounded ad-hoc client query executionADP-041
Relay cursorsfirst <= 100 + afterDeep offset SQL scansADP-010
Production introspectionDisabled on public trafficAutomated type graph enumerationADP-041

Relay connection and typed error union

type Query {
  orders(first: Int = 25, after: String): OrderConnection!
}

union CancelOrderResult = OrderCancelled | OrderAlreadyShipped | ValidationProblem

Pair with DataLoader batching

Use per-request DataLoader keys for foreign references, and keep REST vs GraphQL vs gRPC trade-offs clear across public endpoints.