Skip to content

Conversation

@cecchi
Copy link

@cecchi cecchi commented Nov 1, 2025

🚨 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

  • Adds an option to useOnResolve to skip resolvers that use the default resolver.
  • Adds a corresponding option to useOpentelemetry to skip tracing fields that use the default resolver. This is equivalent to the ignoreTrivialResolveSpans option in @opentelemetry/instrumentation-graphql

Fixes #2132

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Added unit tests for both the enabled and disabled state of this flag.

Test Environment:

  • OS: Mac 26
  • NodeJS: 22.4.1

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

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.

@cecchi cecchi changed the title feat[useOnResolve] add skipDefaultResolvers option feat: add option to ignore default resolvers in opentelemetry Nov 1, 2025
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;
Copy link
Collaborator

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 },
Copy link
Collaborator

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?

Suggested change
{ skipDefaultResolvers: (options.defaultResolvers ?? true) === false },
{ skipDefaultResolvers: (options.defaultResolvers) === false },

Copy link
Collaborator

@EmrysMyrddin EmrysMyrddin left a 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!

@cecchi cecchi requested a review from EmrysMyrddin November 4, 2025 20:23
@cecchi
Copy link
Author

cecchi commented Nov 4, 2025

Thanks - updated 👍

@EmrysMyrddin
Copy link
Collaborator

Oh sorry, I missed it at my first review, can you add a changeset ?

Just run pnpm run changeset and follow instructions :-) You can also edit the generated file if you want to give more explanation or an example, it's just an md file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

useOnResolve: allow skipping default resolvers

2 participants