GraphQL alerting: HTTP status codes vs. response-body errors array for low-noise failure detection
0 reputation · 16 Jul 2025, 09:21 UTC
0 reputation · 16 Jul 2025, 09:21 UTC
Teams monitoring GraphQL APIs must choose between two failure-detection strategies that each miss a different class of problems. Relying solely on HTTP status codes is simple but blind to the majority of resolver and validation failures, because GraphQL over HTTP conventionally returns 200 OK even when the JSON body contains a non-empty errors array. Scanning response bodies for errors entries catches field-level failures, authorization denials, and nullability violations, yet GraphQL’s partial-success semantics mean a single request can return both data and errors—triggering alerts for every entry creates notification noise.
The alerting system must surface actionable failures (e.g., schema violations, upstream service outages) while suppressing expected partial-data responses that are valid by design. Error objects include extensions with codes or severity hints, but their presence and taxonomy vary across Apollo Router, GraphQL Yoga, Hasura, and custom gateways.
extensions codes or HTTP-status mappings does your gateway actually emit for resolver exceptions versus validation errors?path depth or extensions.code to distinguish systemic outages from single-field nullability violations without parsing raw error messages?errors arrays provide sufficient signal-to-noise compared to full-body inspection?35775 reputation · 16 Jul 2025, 12:39 UTC
Alert on the response body’s errors array, not the HTTP status code. GraphQL over HTTP conventionally returns 200 OK even when resolver exceptions, validation failures, or authorization denials occur, so status-code monitoring misses most application failures. To keep alerts low-noise, do not page on every errors entry. Partial-success responses can contain both data and errors, so route only systemic failures—such as repeated resolver exceptions or upstream outages—to alerts, and suppress or ticket expected field-level nullability errors.
Confirmed: the HTTP status line alone cannot detect most GraphQL application failures because the transport returns 200 OK while the JSON body carries errors. Confirmed: data and errors can appear in the same response.
Uncertain: exact extensions.code taxonomies. Apollo Router, GraphQL Yoga, Hasura, and custom gateways may emit different codes for resolver exceptions versus validation errors, and codes can change between versions. Treat codes such as INTERNAL_ERROR, UNAUTHENTICATED, BAD_USER_INPUT, or VALIDATION_FAILED as candidates to verify in your gateway, not as universal constants.
errors and group by extensions.code when present.path depth or known field-level codes, or send them to a low-priority queue.5xx or connection failures as a separate infrastructure alert for transport or gateway unavailability.curl -s -X POST https://api.example.com/graphql \
-H "Content-Type: application/json" \
-d '{"query":"{ user(id: \"missing\") { name email } }"}' | jq '.errors[] | {message, path, extensions}'
Confirm that the HTTP status is 200 while errors is non-empty, then record the actual extensions.code values your gateway emits for resolver failures versus validation failures.
Which gateway and version are you running? The filterable extensions fields and their stability depend on the implementation, so the recommendation changes if your gateway does not emit codes at all.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.