diff --git a/packages/tracing/src/integrations/node/apollo.ts b/packages/tracing/src/integrations/node/apollo.ts index 90ebbf889777..5046a1445d44 100644 --- a/packages/tracing/src/integrations/node/apollo.ts +++ b/packages/tracing/src/integrations/node/apollo.ts @@ -35,7 +35,7 @@ export class Apollo implements Integration { }>('apollo-server-core'); if (!pkg) { - logger.error('Apollo Integration was unable to require apollo-server-core package.'); + __DEBUG_BUILD__ && logger.error('Apollo Integration was unable to require apollo-server-core package.'); return; } @@ -43,7 +43,25 @@ export class Apollo implements Integration { * Iterate over resolvers of the ApolloServer instance before schemas are constructed. */ fill(pkg.ApolloServerBase.prototype, 'constructSchema', function (orig: () => unknown) { - return function (this: { config: { resolvers: ApolloModelResolvers[] } }) { + return function (this: { config: { resolvers?: ApolloModelResolvers[]; schema?: unknown; modules?: unknown } }) { + if (!this.config.resolvers) { + if (__DEBUG_BUILD__) { + if (this.config.schema) { + logger.warn( + 'Apollo integration is not able to trace `ApolloServer` instances constructed via `schema` property.', + ); + } else if (this.config.modules) { + logger.warn( + 'Apollo integration is not able to trace `ApolloServer` instances constructed via `modules` property.', + ); + } + + logger.error('Skipping tracing as no resolvers found on the `ApolloServer` instance.'); + } + + return orig.call(this); + } + const resolvers = arrayify(this.config.resolvers); this.config.resolvers = resolvers.map(model => { diff --git a/packages/tracing/src/integrations/node/graphql.ts b/packages/tracing/src/integrations/node/graphql.ts index 1f16c7a69e41..099c4f84120d 100644 --- a/packages/tracing/src/integrations/node/graphql.ts +++ b/packages/tracing/src/integrations/node/graphql.ts @@ -23,7 +23,7 @@ export class GraphQL implements Integration { }>('graphql/execution/execute.js'); if (!pkg) { - logger.error('GraphQL Integration was unable to require graphql/execution package.'); + __DEBUG_BUILD__ && logger.error('GraphQL Integration was unable to require graphql/execution package.'); return; }