【问题标题】:newrelic/apollo-server-plugin with NEST.JS带有 NEST.JS 的 newrelic/apollo-server-plugin
【发布时间】:2021-05-06 01:00:52
【问题描述】:

我正在使用 NEST.JS 框架,想添加 external 插件 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. 当我启动服务器进行 e2e 测试时,它需要真正的 NewRelic 密钥;有没有不需要真正的密钥就可以开始测试环境的方法?

  2. 为了测试我用真实密钥启动服务器的东西; Missing Key and cannot start agent 错误消失了,但下面是我看到的错误

     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)

【问题讨论】:

  • 你用的是什么版本的nodejs?
  • 节点版本 12.18

标签: node.js graphql nestjs apollo-server newrelic


【解决方案1】:

更新:插件已更新,现在支持 TypeScript。

我最初遇到了同样的错误。我在这里工作的方法是创建一个包含模块声明的typings/newrelic-apollo-server-plugin/index.ts 文件:

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

然后,在我的 NestJS 模块文件中:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    • 2022-01-22
    • 2021-01-08
    • 2017-08-23
    • 2021-02-05
    • 2022-10-07
    • 2021-03-29
    相关资源
    最近更新 更多