Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tracing): Warn if resolvers is not defined in ApolloServer config #5850

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Changes from 1 commit
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
17 changes: 16 additions & 1 deletion packages/tracing/src/integrations/node/apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,22 @@ 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 (this.config.schema) {
logger.warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the debug logging flag here!

'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