This endpoint simulates Cloudflare API Shield's GraphQL malicious query protection. POST a GraphQL query as JSON and the endpoint will parse it, measure size + depth, and either return a normal response or a simulated 403 block.
(cf.api_gateway.graphql.query_size > 30 and cf.api_gateway.graphql.query_depth > 7 and cf.api_gateway.graphql.parsed_successfully) → Block
For demo clarity, this endpoint also blocks when either limit alone is exceeded, so you can show size-only and depth-only attacks separately.
Benign: 200 OK
curl -X POST https://cf-demo-app.dustinburke23nc.workers.dev/graphql \
-H 'Content-Type: application/json' \
-d '{"query":"{ user(id: \"42\") { id name } }"}'
Deeply-nested: 403 Blocked (simulated)
curl -X POST https://cf-demo-app.dustinburke23nc.workers.dev/graphql \
-H 'Content-Type: application/json' \
-d '{"query":"{ a { b { c { d { e { f { g { h { i { j } } } } } } } } } }"}'
See scripts/graphql-attack.sh in cf-demo-app for a 4-payload walkthrough (benign / oversized / deeply-nested / both).