GraphQL Middleware plugin for Bugsnag.
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`)
export interface Options {
apiKey: string
forwardErrors?: boolean
}
const bugsnag = (options: Options): IMiddlewareFunction
property | required | description |
---|---|---|
apiKey |
true | Your Bugsnag API KEY |
forwardErrors |
false | Should middleware forward errors to the client or block them. |
This project is licensed under the MIT License.