Registry / observability / graphql-middleware-sentry

graphql-middleware-sentry

JSON →
library3.2.1jsnpmunverified

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.

npm install graphql-middleware-sentry
INSTALL
IMPORT
SIG · GRAPHQL-MIDDLEWARE
G
graphql-middleware-sentry
observabilityjavascriptv3.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sentry
import { sentry } from 'graphql-middleware-sentry'
import sentry from 'graphql-middleware-sentry'
Named export only; default export does not exist in v3.
Options
import type { Options } from 'graphql-middleware-sentry'
const { Options } = require('graphql-middleware-sentry')
Type import only; not a runtime value.
ExceptionScope
import type { ExceptionScope } from 'graphql-middleware-sentry'
import { ExceptionScope } from 'graphql-middleware-sentry'
Type-only import; using without type keyword will emit an unused runtime import.

Example integrating graphql-middleware-sentry with GraphQL Yoga, capturing errors and enriching Sentry events with context.

import { GraphQLServer } from 'graphql-yoga'; import { sentry } from 'graphql-middleware-sentry'; const typeDefs = ` type Query { hello: String! bug: String! } `; const resolvers = { Query: { hello: () => `Hey there!`, bug: () => { throw new Error(`Many bugs!`); } } }; const sentryMiddleware = sentry({ config: { dsn: process.env.SENTRY_DSN ?? '', environment: process.env.NODE_ENV }, withScope: (scope, error, context) => { scope.setUser({ id: context.authorization.userId }); scope.setExtra('body', context.request.body); }, }); const server = new GraphQLServer({ typeDefs, resolvers, middlewares: [sentryMiddleware] }); server.start(() => console.log('Server running on http://localhost:4000'));
Debug
Known issues
breakingv3.0.0 removed the `dsn` configuration option; use `config.dsn` instead.
fix
Pass DSN via `config: { dsn: '...' }` instead of top-level `dsn`.
affects: >=3.0.0
breakingv2.0.0 migrated from `raven` to `@sentry/node`. Old raven-based configs are invalid.
fix
Replace `raven` with `@sentry/node` and use `Sentry.init(config)` before passing sentryInstance.
affects: >=2.0.0
deprecatedThe `reportError` option requires filtering by message string or instance; no built-in filtering is provided.
fix
Implement a custom `reportError` function as shown in the README.
affects: >=3.0.0
gotchaIf both `sentryInstance` and `config` are provided, the plugin will use the instance and ignore config.
fix
Provide only one of `sentryInstance` or `config`; if both given, only `sentryInstance` takes effect.
affects: >=3.1.0
Errors
Common errors & fixes
Cannot find module 'graphql-middleware-sentry'
Package not installed or wrong peer dependencies.
fix
Run `npm install graphql-middleware-sentry @sentry/node graphql graphql-middleware`.
TypeError: sentry is not a function
Using default import instead of named import.
fix
Use `import { sentry } from 'graphql-middleware-sentry'` instead of `import sentry from ...`.
Property 'config' is missing in type '{ dsn: string; }'
Passing `dsn` as top-level option in v3.
fix
Set `config: { dsn: '...' }` instead of `dsn: '...'`.
Upgrade
Version history
3.2.1latest on npm
Audit
Dependencies
@sentry/noderequiredpeer dependency for Sentry SDK initialization
graphqlrequiredpeer dependency for GraphQL schema/execution
graphql-middlewarerequiredpeer dependency for middleware interface
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
graphql-middleware-sentry — npm install graphql-middleware-sentry · libregistry