The handleErrors
middleware option now allows you to write your own formatters for any GraphQLErrors thrown during GraphQL execution; this overrides extendedErrors
and showErrorStack
- you get full control over the errors, including the ability to add or remove errors should you so desire (not recommended!).
The handleErrors
option is a function that receives 3 parameters:
- the list of GraphQLErrors
- the
req
object - the
res
object
It must return the array of errors to be added to the JSON HTTP response.
You could use this to add extra detail to the errors, handle translations based on request headers, set the response statusCode based on any errors, track errors via your error tracking service of choice, and much more.
This feature is thanks to @pyramation 🙏
This release also adds the X-GraphQL-Event-Stream
header to /graphql
responses when --watch
mode is enabled, allowing tools to subscribe to the event stream for changes.