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.
| Control | Threshold | Attack blocked | Rule |
|---|---|---|---|
| Query depth cap | Max 8 to 10 nesting levels | Cyclic user.orders.user.orders recursion | ADP-041 |
| Complexity cost budget | Weighted list multipliers | Product of nested first: 100 lists | ADP-041 |
| Persisted queries | SHA-256 operation allowlist | Unbounded ad-hoc client query execution | ADP-041 |
| Relay cursors | first <= 100 + after | Deep offset SQL scans | ADP-010 |
| Production introspection | Disabled on public traffic | Automated type graph enumeration | ADP-041 |
Relay connection and typed error union
type Query {
orders(first: Int = 25, after: String): OrderConnection!
}
union CancelOrderResult = OrderCancelled | OrderAlreadyShipped | ValidationProblemPair with DataLoader batching
Use per-request DataLoader keys for foreign references, and keep REST vs GraphQL vs gRPC trade-offs clear across public endpoints.