GraphQL depth and static complexity score
Parses a GraphQL document (query, mutation or subscription) per the June 2018 spec and returns depth, field count, alias count, fragment list, cycle detection and a static complexity score. Complexity uses the common 'Σ field-score × list-multiplier' model: a listFields config maps parent-type + field-name to either a constant multiplier or a field argument name to read (e.g. 'first', 'limit'), with a defaultListMultiplier fallback. Returns fail when depth or complexity exceed configured limits, or the query is syntactically invalid or has a fragment cycle. No schema is required; this is a pre-schema gate for rate limiting.
What you get
A depth-50 nested query from a public token is the oldest GraphQL outage. One middleware call blocks it with the same scoring the big GraphQL proxies use.
Call it
Send the JSON body below to https://agents.writerslogic.com/api/v1/graphql-cost. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.
curl -i -X POST https://agents.writerslogic.com/api/v1/graphql-cost \
-H 'content-type: application/json' \
-d '{"query":"query Shop { products(first: 20) { edges { node { id title reviews(first: 5) { body } } } } }","listFields":{"Query":{"products":{"multiplier":"first"}},"Product":{"reviews":{"multiplier":"first"}}},"maxDepth":15,"maxComplexity":2000}'
Input
| Field | Type | Required | Description |
|---|---|---|---|
query | string; length 0..200000 | yes | The GraphQL document text. |
variables | object | no | Variable values, used only to resolve list-argument multipliers like first: $first. |
listFields | object | no | Per-type field multiplier config. See description for shape. |
defaultListMultiplier | integer | no | Fallback multiplier for list fields not declared in listFields. Default 10. |
operationName | string; length 0..100 | no | Pick this operation; defaults to the first. |
maxDepth | integer | no | Fail if depth exceeds this. Default 15. |
maxComplexity | integer | no | Fail if complexity exceeds this. Default 1000. |
Example request body
{
"query": "query Shop { products(first: 20) { edges { node { id title reviews(first: 5) { body } } } } }",
"listFields": {
"Query": {
"products": {
"multiplier": "first"
}
},
"Product": {
"reviews": {
"multiplier": "first"
}
}
},
"maxDepth": 15,
"maxComplexity": 2000
}
Result
The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.
| Field | Type | Required | Description |
|---|---|---|---|
status | string; one of "pass", "fail", "unknown", "unsupported" | no | pass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass. |
valid | boolean | no | |
operation | string | no | |
operationType | string; one of "query", "mutation", "subscription" | no | |
depth | integer | no | |
fieldCount | integer | no | |
aliasCount | integer | no | |
complexity | integer | no | |
overLimit | boolean | no | |
fragments | array<string> | no | |
witnesses | array<object> | no | |
versions | object | no | Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile). |
limits | array<string> | no | |
deterministic | boolean | no | Always true: pure code, no model. |
Pay and connect
Available through: x402 (USDC on Base), MCP. MCP clients reach it through the code-preflight-kit package.
Machine-readable
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent