graphql-middleware-sentry
GraphQL Middleware plugin for Sentry.
Usage
With GraphQL Yoga
serve.start`Server running on http://localhost:4000`
Using a Sentry instance
In cases where you want to use your own instance of Sentry to use it in other places in your application you can pass the sentryInstance
. The config
property should not be passed as an option.
Example usage with a Sentry instance
Sentry.init
API & Configuration
Sentry context
To enrich events sent to Sentry, you can modify the context.
This can be done using the withScope
configuration option.
The withScope
option is a function that is called with the current Sentry scope, the error, and the GraphQL Context.
Filtering Out Custom Errors
To filter out custom errors thrown by your server (such as "You Are Not Logged In"), use the reportError
option and return a boolean for whether or not the error should be sent to sentry.
Options
property | required | description |
---|---|---|
sentryInstance |
false | Sentry's instance |
config |
false | Sentry's config object |
withScope |
false | Function to modify the Sentry context to send with the captured error. |
captureReturnedErrors |
false | Capture errors returned from other middlewares, e.g., graphql-shield returns errors from rules and resolvers |
forwardErrors |
false | Should middleware forward errors to the client or block them. |
reportError |
false | Function that passes res as the parameter and accepts a boolean callback for whether or not the error should be captured |
Note
If sentryInstance
is not passed then config.dsn
is required and vice-versa.
License
This project is licensed under the MIT License.