GraphQL Complexity Estimator
Estimate a GraphQL operation's cost from a schema: one point per field, multiplied for list fields and multiplied again through each nesting level.
What the GraphQL Complexity Estimator does
The rule is stated once and applied uniformly. A leaf field costs 1, or the list multiplier when its declared type is a list. A field with a selection set costs its own weight times one plus the sum of its children.
Every selected field is printed with its own cost, so a total that looks wrong can be traced to the line that caused it.
This is a static estimate, not a measurement: it does not know how many rows a list returns. Fragment spreads are refused rather than skipped, because ignoring one would under-report the cost.
How to use it
Paste the schema into the GraphQL schema box and the operation into the Operation box, or press Run with the examples already there.
Set the List multiplier to the page size you expect from a list field, then press Run again.
Read the Cost estimate: the per-field lines add up to the total, and the Selected fields count is the number of lines.
Worked example
Input:
type Query {
hero: Hero
}
type Hero {
name: String
friends: [Hero]
}
Output:
Operation: anonymous
Estimated cost: 21 (list multiplier 10)
Selected fields: 3
Hero.name: 1
Hero.friends [list x10]: 20
Query.hero: 21
Why it runs in your browser
The result is produced on this page with JavaScript, so it works offline after the page loads and nothing you enter is sent anywhere.
A cost estimate you can check by hand: every selected field costs one, a field that returns a list costs the list multiplier instead, and a parent costs its own weight times one plus its children.
The page prints the per-field breakdown, so the total is arithmetic you can re-do rather than a number you have to trust.
What it does, and what it does not
The rule is stated once and applied uniformly. A leaf field costs 1, or the list multiplier when its declared type is a list. A field with a selection set costs its own weight times one plus the sum of its children.
Every selected field is printed with its own cost, so a total that looks wrong can be traced to the line that caused it.
This is a static estimate, not a measurement: it does not know how many rows a list returns. Fragment spreads are refused rather than skipped, because ignoring one would under-report the cost.
How to use GraphQL Complexity Estimator
Paste the schema into the GraphQL schema box and the operation into the Operation box, or press Run with the examples already there.
Set the List multiplier to the page size you expect from a list field, then press Run again.
Read the Cost estimate: the per-field lines add up to the total, and the Selected fields count is the number of lines.
What to Expect
Best for
- Comparing two operations before shipping one
- Explaining a rate-limit cost to a reviewer
Not ideal for
- Measuring real latency, which this page does not do
- Operations that use fragments, which are refused
What this tool keeps
- One line per selected field with its own cost
- The multiplier stated beside the total
What may need cleanup
- A list's real page size still has to be chosen by you
- A cost limit per client is your policy, not this page's
Common errors
- The page refuses it: field friends does not exist on type Hero
Example use cases
- Reviewing a deep query before it reaches production
- Comparing a costly and a cheap version of one operation
Sample input
GraphQL schema: type Query { …
Sample output
Cost estimate: Operation: anonymous …
Who this is for
- API owners setting a cost budget
- Frontend developers inheriting a deep query
Frequently asked questions
How is the total computed?
A leaf costs 1, or the list multiplier if its type is a list. A parent costs its own weight times one plus its children's total. The printed lines are the terms of that sum.
Why refuse a fragment spread?
A spread's cost lives in the fragment definition. Skipping it would print a total lower than the real one, so the page refuses and asks you to inline the fields.
Is this a security control?
No. It is a planning estimate over a static schema. Enforcing a limit belongs on the server, where the response size is known.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.