@travelerdev/nestjs-sentry-graphql
v4.3.0
Published
Provides an injectable sentry.io client to provide enterprise logging of nestjs modules with GraphQL
Downloads
3,416
Readme
About
@travelerdev/nestjs-sentry-graphql
is an extension of @travelerdev/nestjs-sentry
, which is
itself built upon the foundation developed by
@ntegral/nestjs-sentry
.
This package implements a module, SentryModule
which when imported into your nestjs project
provides a Sentry.io client to any class that injects it. This lets Sentry.io be worked into your
dependency injection workflow without having to do any extra work outside of the initial setup.
It also implements a class, GraphqlInterceptor
, which can intercept resolver errors into Sentry.
If you do not use graphql, you should consider using @travelerdev/nestjs-sentry
instead to avoid
unnecessary dependencies.
Getting Started
For details getting started instructions, see @travelerdev/nestjs-sentry
Quick Start
npm install --save @travelerdev/nestjs-sentry-graphql @nestjs/graphql
To get started with @travelerdev/nestjs-sentry-graphql
you should add an import of
SentryModule.forRoot
to your app's root module.
import { Module } from '@nestjs-common';
import { SentryModule } from '@travelerdev/nestjs-sentry-graphql';
@Module({
imports: [
SentryModule.forRoot({
dsn: '<< your sentry_io_dsn >>',
debug: true | false,
environment: 'dev' | 'production' | 'some_environment',
release: 'some_release', | null, // must first create a release in sentry.io dashboard
logLevels: ["debug"] //based on sentry.io loglevel //
}),
],
})
export class AppModule {}
There are other instantiation methods documented in @travelerdev/nestjs-sentry
's readme.
GraphQL Interceptor
The GraphqlInterceptor in this package can be used at the App level to intercept resolver errors and pass them up to Sentry.
Using graphql interceptor globally:
import { Module } from '@nestjs/common';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { GraphqlInterceptor } from '@travelerdev/nestjs-sentry-graphql';
@Module({
....
providers: [
{
provide: APP_INTERCEPTOR,
useFactory: () => new GraphqlInterceptor(),
},
],
})
export class AppModule {}