Registry /
observability / graphql-middleware-sentry
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
muslnode 18–226 runs
build_error
glibcnode 18–226 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'));
Errors
Common errors & fixes
Cannot find module 'graphql-middleware-sentry'
Package not installed or wrong peer dependencies.
fixRun `npm install graphql-middleware-sentry @sentry/node graphql graphql-middleware`.
TypeError: sentry is not a function
Using default import instead of named import.
fixUse `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.
fixSet `config: { dsn: '...' }` instead of `dsn: '...'`. Audit
Dependencies
@sentry/noderequiredpeer dependency for Sentry SDK initialization
graphqlrequiredpeer dependency for GraphQL schema/execution
graphql-middlewarerequiredpeer dependency for middleware interface