Skip to content

Pass Sentry instance #41

@nickluger

Description

@nickluger

Feature request: Pass a preconfigured sentry instance to graphql-sentry-middleware

How it works now and why this is problematic

Currently it's only possible to pass a Sentry configuration and graphq-middleware-sentry will initialize the Sentry instance on its own. This behaviour is suboptimal, if we want to re-use a sentry instance in other places with the same configuration, for example to manually capture certain errors, without throwing in the resolver.

Also if you install the newest version of Sentry and keep your modules up to date, graphql-sentry-middleware will always lag behind your version of Sentry. Which will result in two versions of sentry in your node_modules! This also raises the question, whether Sentry could be a peer dependency.

The current workaraound:

// some config file
const sentryConfig = {
          dsn: process.env.SENTRY_DSN,
          environment: process.env.NODE_ENV,
        // ... much more config
        }
// ...

// createSentryMiddleware.ts
import { sentryConfig } from "./sentryConfig";

sentry({
        config: sentryConfig,
});
// ...

// Sentry.ts
import * as Sentry from "@sentry/node";
import { sentryConfig } from "./sentryConfig";


Sentry.init(sentryConfig);

export { Sentry };

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions