Expand description
Error vocabulary and mapping.
A GraphQL response is an HTTP 200 (under application/json), so it
never passes through Autumn’s problem-details filter, which is where
server-side detail is normally redacted. This module is that filter for
GraphQL:
IntoGraphqlError/GraphqlResultExt::gqlturn anAutumnErrorinto a field error. Client errors (4xx) keep their message; server errors (5xx) are logged and replaced by a generic message. The HTTP status travels inextensions.statusand a stable machine-readablecodeinextensions.code, so a client can tell a422from a503without an HTTP status to read.- Validation failures carry their per-field messages in
extensions.fieldsas well as in the message. - Errors a resolver produced without a code (a bare
?on some library error,ctx.data::<T>()?, …) are “unexpected”. Whenmask_unexpected_errorsis on, the plugin replaces their message before the response leaves the process. Give an error a code to show its message to clients.
Modules§
- codes
- Stable values for
errors[].extensions.code.
Constants§
- INTERNAL_
MESSAGE - The generic message a redacted or masked error carries.
Traits§
- Graphql
Result Ext ?-friendly conversion for resolver results.- Into
Graphql Error - Conversion into a coded, redaction-safe GraphQL error.
Functions§
- code_
for_ status - The
extensions.codefor an HTTP status. - error_
code - Read
extensions.codeoff a server error, if any. - finalize_
errors - Post-process a response’s errors: give every error a code, and mask
unexpected execution errors when
maskis on. - graphql_
error - Build a coded GraphQL error:
extensions.codeand, when given,extensions.status. - is_
execution_ error - Whether
errorwas raised during execution (it has a response path) rather than while parsing or validating the document. - request_
error - Build a pre-execution
ServerErrorcarryingcodeandstatus, plus any extra extension values.