{"id":18399,"library":"graphql-middleware-sentry","title":"graphql-middleware-sentry","description":"GraphQL Middleware plugin for Sentry error tracking (v3.2.1). Integrates Sentry with GraphQL middleware to automatically capture resolver errors. Key features: configurable withScope for enriching Sentry events, reportError filter for custom errors, support for forwarded or captured errors. Requires @sentry/node (^5.2.0), graphql (^0.11-14), and graphql-middleware (^2-4). Ships TypeScript types. Last released in 2019; actively maintained.","status":"active","version":"3.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/BrunoScheufler/graphql-middleware-sentry","tags":["javascript","typescript"],"install":[{"cmd":"npm install graphql-middleware-sentry","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-middleware-sentry","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-middleware-sentry","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for Sentry SDK initialization","package":"@sentry/node","optional":false},{"reason":"peer dependency for GraphQL schema/execution","package":"graphql","optional":false},{"reason":"peer dependency for middleware interface","package":"graphql-middleware","optional":false}],"imports":[{"note":"Named export only; default export does not exist in v3.","wrong":"import sentry from 'graphql-middleware-sentry'","symbol":"sentry","correct":"import { sentry } from 'graphql-middleware-sentry'"},{"note":"Type import only; not a runtime value.","wrong":"const { Options } = require('graphql-middleware-sentry')","symbol":"Options","correct":"import type { Options } from 'graphql-middleware-sentry'"},{"note":"Type-only import; using without type keyword will emit an unused runtime import.","wrong":"import { ExceptionScope } from 'graphql-middleware-sentry'","symbol":"ExceptionScope","correct":"import type { ExceptionScope } from 'graphql-middleware-sentry'"}],"quickstart":{"code":"import { GraphQLServer } from 'graphql-yoga';\nimport { sentry } from 'graphql-middleware-sentry';\n\nconst typeDefs = `\n  type Query {\n    hello: String!\n    bug: String!\n  }\n`;\n\nconst resolvers = {\n  Query: {\n    hello: () => `Hey there!`,\n    bug: () => { throw new Error(`Many bugs!`); }\n  }\n};\n\nconst sentryMiddleware = sentry({\n  config: {\n    dsn: process.env.SENTRY_DSN ?? '',\n    environment: process.env.NODE_ENV\n  },\n  withScope: (scope, error, context) => {\n    scope.setUser({ id: context.authorization.userId });\n    scope.setExtra('body', context.request.body);\n  },\n});\n\nconst server = new GraphQLServer({\n  typeDefs,\n  resolvers,\n  middlewares: [sentryMiddleware]\n});\n\nserver.start(() => console.log('Server running on http://localhost:4000'));","lang":"typescript","description":"Example integrating graphql-middleware-sentry with GraphQL Yoga, capturing errors and enriching Sentry events with context."},"warnings":[{"fix":"Pass DSN via `config: { dsn: '...' }` instead of top-level `dsn`.","message":"v3.0.0 removed the `dsn` configuration option; use `config.dsn` instead.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace `raven` with `@sentry/node` and use `Sentry.init(config)` before passing sentryInstance.","message":"v2.0.0 migrated from `raven` to `@sentry/node`. Old raven-based configs are invalid.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Implement a custom `reportError` function as shown in the README.","message":"The `reportError` option requires filtering by message string or instance; no built-in filtering is provided.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Provide only one of `sentryInstance` or `config`; if both given, only `sentryInstance` takes effect.","message":"If both `sentryInstance` and `config` are provided, the plugin will use the instance and ignore config.","severity":"gotcha","affected_versions":">=3.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install graphql-middleware-sentry @sentry/node graphql graphql-middleware`.","cause":"Package not installed or wrong peer dependencies.","error":"Cannot find module 'graphql-middleware-sentry'"},{"fix":"Use `import { sentry } from 'graphql-middleware-sentry'` instead of `import sentry from ...`.","cause":"Using default import instead of named import.","error":"TypeError: sentry is not a function"},{"fix":"Set `config: { dsn: '...' }` instead of `dsn: '...'`.","cause":"Passing `dsn` as top-level option in v3.","error":"Property 'config' is missing in type '{ dsn: string; }'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}