Rockyboy_ruby
Rockyboy_ruby

Reputation: 233

newrelic/apollo-server-plugin with NEST.JS

I am using NEST.JS framework and want to add external plugin New Relic Apollo Server plugin.

apollo-server-fastify: "^2.19.2"
@newrelic/apollo-server-plugin: "^0.1.2"

import { apolloServerNewRelicPlugin } from '@newrelic/apollo-server-plugin';

GraphQLModule.forRootAsync({
  imports: [ConfigModule],
  inject: [ConfigService],
  ....
  plugins: [apolloServerNewRelicPlugin],
}),
  1. When I start server for e2e test it required real NewRelic key ; is there a way to start for test environment without requiring real key ?

  2. To test out things I started server with real key; Missing Key and cannot start agent error disappeared but below is the error I am seeing

     UnhandledPromiseRejectionWarning: TypeError: Cannot use 'in' operator to search for '__internal_plugin_id__' in undefined
    my-application    |     at Object.pluginIsInternal (/usr/src/app/node_modules/apollo-server-fastify/node_modules/apollo-server-core/dist/plugin/internalPlugin.js:5:37)

Upvotes: 2

Views: 1563

Answers (1)

lsouza
lsouza

Reputation: 2488

Update: the plugin has been updated and it supports TypeScript now.

I've had the same error initially. The way I made it work here was to create a typings/newrelic-apollo-server-plugin/index.ts file containing a module declaration:

declare module '@newrelic/apollo-server-plugin'

Then, in my NestJS module file:

import apolloServerNewRelicPlugin from '@newrelic/apollo-server-plugin'

@Module({
  imports: [
    ...
    GraphQLModule.forRoot({
      ...
      plugins: [apolloServerNewRelicPlugin],
    }),

Upvotes: 1

Related Questions