Pick the fix
A public GraphQL API slows to a crawl when someone queries friends of friends of friends. First defence?
Hint 1 of 1
Who decides how expensive a query can be?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Enforce query depth and complexity limits (and prefer persisted queries)
Correct. Reject expensive queries before running them.
In GraphQL the client chooses how deep a query goes, so one request can fan out into millions of resolver calls. Rejecting queries over a depth or cost budget before running them caps that work.
Why not the others?
- B Add more servers. One crafted query can still cost more than any fleet.
- C Switch every query to GET. Changes caching, not cost.
- D Remove the friends field. Removes a feature instead of limiting abuse.