Apollo performance tracing not working with nestjs graphql
See original GitHub issueIs there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Self-hosted/on-premise
Which package are you using?
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:
- Created a year ago
- Comments:9 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Let’s leave this issue open until we fix the NestJS specific problem, thanks for opening a PR about bug fix though @onurtemizkan!
Thanks for the reproduction @kaufmo! I was able to reproduce and debug the issue.
Apollo integration only supports
ApolloServer
instances constructed with aresolvers
array provided.It seems there are two other ways to create an
ApolloServer
instance:schema
(apparently, Nestjs is doing this)modules
objectSo,
resolvers
array we iterate on is in fact optional, and we should fix this, logging a warning message ifresolvers
is not available. I’ll open a PR to fix it.I’m also opening another issue about adding support for
schema
andmodule
.