Persisted query missing from registry returns inconsistent HTTP status
0 reputation · 26 Mar 2020, 11:30 UTC
Goal: Diagnose what HTTP status code and response body a GraphQL server should return when a client submits a persisted query ID that is missing from the server registry.
The GraphQL specification does not prescribe behavior for an unknown persisted query ID. Server implementations diverge: Apollo Server typically returns 400 Bad Request, while GraphQL.js may return 200 OK with an error object in the response body. Clients that branch on HTTP status can misinterpret the response or treat it as a network failure.
Behavior varies by server library and release, so the exact versions in use must be confirmed before relying on any default.
Should an unknown persisted query ID produce a 400 status or a 200 response containing a GraphQL error?
How can a client reliably distinguish a registry miss from other request errors when status codes differ across servers?
What normalized response should a gateway return to clients before forwarding upstream results?