Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions packages/tracing/src/integrations/node/apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,33 @@ 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;
}

/**
* 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 => {
Expand Down
2 changes: 1 addition & 1 deletion packages/tracing/src/integrations/node/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down