github graphile/crystal v4.0.0-beta.4
Ability to override how errors are handled with 'handleErrors'

latest releases: pgl5b21, v4.14.0, v4.13.0...
6 years ago

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:

  1. the list of GraphQLErrors
  2. the req object
  3. 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.

Don't miss a new crystal release

NewReleases is sending notifications on new releases.