question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apollo performance tracing not working with nestjs graphql

See original GitHub issue

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which package are you using?

@sentry/node

SDK Version

7.13.0

Framework Version

@nestjs/graphql: ^10.0.0
@nestjs/apollo: ^10.0.0
apollo-server-core": ^3.3.0
apollo-server-express: ^3.3.0

Link to Sentry event

No response

Steps to Reproduce

Im running a nestjs graphql api which uses apollo-server behind. I want to integrate the Apollo tracing: https://docs.sentry.io/platforms/node/performance/database/opt-in/#apollo-server-integration but I’m always getting an error.

It looks like the problem is that the integration cannot find the resolvers in constructSchema? See here my resolvers are empty https://github.com/getsentry/sentry-javascript/blob/master/packages/tracing/src/integrations/node/apollo.ts#L49

Can somebody help me how can i fix that?

Expected Result

Expected result would be getting tracing into my sentry instance 😅

Actual Result

Error on API startup

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at /dist/sentry.ts:58:28
    at Array.map (<anonymous>)
    at ApolloServer.<anonymous> (/dist/sentry.ts:56:51)
    at new ApolloServerBase (xxx/node_modules/apollo-server-core/src/ApolloServer.ts:330:18)
    at new ApolloServer (xxx/node_modules/apollo-server-express/src/ApolloServer.ts:55:1)
    at ApolloDriver.registerExpress (xxx/node_modules/@nestjs/apollo/dist/drivers/apollo-base.driver.js:77:30)
    at ApolloDriver.registerServer (xxx/node_modules/@nestjs/apollo/dist/drivers/apollo.driver.js:38:24)
    at ApolloDriver.start (xxx/node_modules/@nestjs/apollo/dist/drivers/apollo.driver.js:23:20)
    at GraphQLModule.onModuleInit (xxx/node_modules/@nestjs/graphql/dist/graphql.module.js:105:9)

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
AbhiPrasadcommented, Sep 28, 2022

Let’s leave this issue open until we fix the NestJS specific problem, thanks for opening a PR about bug fix though @onurtemizkan!

1reaction
onurtemizkancommented, Sep 28, 2022

Thanks for the reproduction @kaufmo! I was able to reproduce and debug the issue.

Apollo integration only supports ApolloServer instances constructed with a resolvers array provided.

It seems there are two other ways to create an ApolloServer instance:

So, resolvers array we iterate on is in fact optional, and we should fix this, logging a warning message if resolvers is not available. I’ll open a PR to fix it.

I’m also opening another issue about adding support for schema and module.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Reference: Inline trace plugin - Apollo GraphQL Docs
This plugin enables your GraphQL server to include encoded performance and usage traces inside responses. This is primarily designed for use with Apollo...
Read more >
graphql plugin severely degrades performance #2109 - GitHub
The new plugin is available in the latest version of dd-trace. It seems to have similar performance issues that we'll be looking into,...
Read more >
GraphQL + TypeScript - A progressive Node.js framework
It's an elegant approach that solves many problems typically found with REST APIs. For background, we suggest reading this comparison between GraphQL and...
Read more >
Extremely slow Apollo gateway / server responses
We're facing some challenging performance issues with some queries taking an ... All 3 use NestJS 7 on top of Apollo Server +...
Read more >
How to build a GraphQL API with NestJS - LogRocket Blog
LogRocket is a frontend application monitoring solution that lets you replay problems as if they happened in your own browser. Instead of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found