-
Notifications
You must be signed in to change notification settings - Fork 134
feat: add option to ignore default resolvers in opentelemetry #2747
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
base: main
Are you sure you want to change the base?
Conversation
| if ((!opts.skipIntrospection || !isIntrospectionType(type)) && isObjectType(type)) { | ||
| for (const field of Object.values(type.getFields())) { | ||
| if ((field as { [hasWrappedResolveSymbol]?: true })[hasWrappedResolveSymbol]) continue; | ||
| if (opts.skipDefaultResolvers && !field.resolve) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can also check that if it exists, it is different from defaultFieldResolver from graphql package ?
| }), | ||
| return () => {}; | ||
| }, | ||
| { skipDefaultResolvers: (options.defaultResolvers ?? true) === false }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you already are making a strict equal against false, I don't think it is necessary to add a default value? Or it is just for clarity?
| { skipDefaultResolvers: (options.defaultResolvers ?? true) === false }, | |
| { skipDefaultResolvers: (options.defaultResolvers) === false }, |
EmrysMyrddin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much! That's greatly appreciated 🙂
I've leaved a few comments, but otherwise it looks good to me!
Great work!
|
Thanks - updated 👍 |
|
Oh sorry, I missed it at my first review, can you add a changeset ? Just run |
🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.
Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of
the pull request.
Description
useOnResolveto skip resolvers that use the default resolver.useOpentelemetryto skip tracing fields that use the default resolver. This is equivalent to theignoreTrivialResolveSpansoption in @opentelemetry/instrumentation-graphqlFixes #2132
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Added unit tests for both the enabled and disabled state of this flag.
Test Environment:
Checklist:
CONTRIBUTING doc and the
style guidelines of this project
Further comments
Unfortunately I did not realize @Akryum had proposed part of the same change in #2133 until I started to write this PR. This PR includes tests and the corresponding change to
useOpentelemetry, so hopefully it can be merged.