graphql-notify-errors

1.0.0 • Public • Published

graphql-notify-errors

npm version npm downloads devDependency Status

Send errors captured by graphql to sentry, bugsnag or similar

Installation

npm i graphql-notify-errors

Use

const { formatError, GraphQLError } = require('graphql')
const express = require('express')
const Raven = require('raven')
const NotifyErrors = require('graphql-notify-errors')
 
Raven.config(process.env.SENTRY_DSN).install()
 
const filter = err => !(err instanceof GraphQLError)
const options = {
  formatError,
  filter,
  notify: Raven.captureException
}
const notifyErrors = new NotifyErrors(options)
const app = express()
app.use('/graphql', graphqlExpress(req => {
    return {
      schema,
      context: { req },
      formatError: err => notifyErrors.formatError(err)
    }
  })
)

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i graphql-notify-errors

Weekly Downloads

14

Version

1.0.0

License

MIT

Unpacked Size

6.01 kB

Total Files

5

Last publish

Collaborators

  • lgatica