Skip to content
Calcrivo

GraphQL Query Complexity Calculator

Compute the depth × breadth cost of a GraphQL query, the resolver load it implies and whether your cost limit would reject it.

Inputs

levels
fields
items
units
copies
units
ms

Query Cost

7,541,379,300units

Nodes Resolved

754,137,930

Cost of One Copy

754,137,930units

Resolver Time

3,016,551.72seconds

Amplification vs a One-Field Query

7,541,379,300×

Cost Limit Decision

Rejected — the query exceeds the cost limit by 7541379×

Step by step

  1. Values used

    Query depth = 6 levels; Selected fields per level = 3 fields; List items returned per level = 10 items; Cost units per resolved field = 1 units; Aliased or batched copies per request = 10 copies; Configured query cost limit = 1,000 units; Resolver latency per node = 0.4000 ms

  2. GraphQL Query Complexity

    A query selecting b fields per level over lists of p items branches by b × p at each of d levels, so nodes = Σ(b × p)^i for i = 1…d, a geometric series equal to r(r^d − 1) ÷ (r − 1) with r = b × p.

  3. Cost and load

    total cost = nodes × cost per field × aliased copies; resolver time = nodes × copies × latency per node.

  4. Query Cost

    = 7,541,379,300 units

  5. Nodes Resolved

    = 754,137,930

  6. Cost of One Copy

    = 754,137,930 units

  7. Resolver Time

    = 3,016,551.72 seconds

  8. Amplification vs a One-Field Query

    = 7,541,379,300 ×

  9. Cost Limit Decision

    = Rejected — the query exceeds the cost limit by 7541379×

How it works

Cost grows geometrically with depth because every level multiplies by the branching factor, which is why a depth limit alone is a blunt control and a cost limit is the real defence. Aliasing multiplies the whole subtree within a single request, so it is counted separately — that is the batching attack. One nested query on a schema with cyclic relationships can resolve millions of nodes, which is a self-inflicted denial of service that no rate limit catches because it is a single request.

Formulas

GraphQL Query Complexity

A query selecting b fields per level over lists of p items branches by b × p at each of d levels, so nodes = Σ(b × p)^i for i = 1…d, a geometric series equal to r(r^d − 1) ÷ (r − 1) with r = b × p.

b
Fields selected per level
p
List items returned per level
d
Query depth
r
Branching factor b × p

Cost and load

total cost = nodes × cost per field × aliased copies; resolver time = nodes × copies × latency per node.

aliased copies
The same subtree repeated under different aliases in one request
cost per field
Static cost assigned to a resolved field

Frequently Asked Questions

How is GraphQL Query Complexity calculated?

A query selecting b fields per level over lists of p items branches by b × p at each of d levels, so nodes = Σ(b × p)^i for i = 1…d, a geometric series equal to r(r^d − 1) ÷ (r − 1) with r = b × p. Cost grows geometrically with depth because every level multiplies by the branching factor, which is why a depth limit alone is a blunt control and a cost limit is the real defence. Aliasing multiplies the whole subtree within a single request, so it is counted separately — that is the batching attack.

Why does GraphQL Query Complexity matter?

One nested query on a schema with cyclic relationships can resolve millions of nodes, which is a self-inflicted denial of service that no rate limit catches because it is a single request.

What values do I need to enter?

This calculator takes 7 inputs: Query depth, Selected fields per level, List items returned per level, Cost units per resolved field, Aliased or batched copies per request, Configured query cost limit, Resolver latency per node. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.

Is a depth limit enough on its own?

No. A shallow query can still be enormous — a depth of three over three list fields of a thousand items each is a billion nodes — and a strict depth limit blocks legitimate nested queries. Assign static costs to fields, multiply by declared page sizes, reject over a budget, and cap aliases per request as well.

You might also need