1.0.0 • Published 6 years ago

graphql-middleware-bugsnag v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

graphql-middleware-bugsnag

GraphQL Middleware plugin for Bugsnag.

Usage

With GraphQL Yoga

import { GraphQLServer } from 'graphql-yoga'
import { bugsnag } from 'graphql-middleware-bugsnag'

const typeDefs = `
  type Query {
    hello: String!
    bug: String!
  }
`

const resolvers = {
  Query: {
    hello: () => `Hey there!`
    bug: () => {
      throw new Error(`Many bugs!`)
    }
  }
}

const bugsnagMiddleware = bugsnag({
  apiKey: BUGSNAG_API_KEY
})

const server = GraphQLServer({
  typeDefs,
  resolvers,
  middlewares: [bugsnagMiddleware]
})

serve.start(() => `Server running on http://localhost:4000`)

API & Configuration

export interface Options {
  apiKey: string
  forwardErrors?: boolean
}

const bugsnag = (options: Options): IMiddlewareFunction

Options

propertyrequireddescription
apiKeytrueYour Bugsnag API KEY
forwardErrorsfalseShould middleware forward errors to the client or block them.

License

This project is licensed under the MIT License.