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(@nestjs/graphql): set unique ids on resolvers to fix cache errors #2408

Merged

Conversation

koyedele
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

The resolver metadata cache currently uses the resolver name for the key as shown below

https://github.com/nestjs/nest/blob/39ec4cda7363aac3551ff0f1b83feb41ba2f0bf6/packages/core/helpers/handler-metadata-storage.ts#L60-L63

This causes issues if we have two resolvers in different modules but with the same name and identical method signatures. For controllers, each controller gets a unique ID that is used as the key in the cache as shown below:

https://github.com/nestjs/nest/blob/39ec4cda7363aac3551ff0f1b83feb41ba2f0bf6/packages/core/injector/module.ts#L461-L462

Add code to set up unique IDs for resolvers as well so that cache retrieval is correct.

Issue Number: #1907

What is the new behavior?

Each resolver gets a unique ID so that it can be retrieved correctly from the metadata cache. The solution re-uses the ID key that controllers also use so I worry that that may cause confusion.

Does this PR introduce a breaking change?

  • Yes
  • No

The resolver metadata cache currently uses the resolver name for the
key but this causes issues if we have two resolvers in different modules
but with the same name and identical method signatures. For controllers,
each controller gets a unique ID that is used as the key in the cache.
Add code to set up unique IDs for resolvers as well so that cache
retrieval is correct.

Fixes nestjs#1907
@kamilmysliwiec kamilmysliwiec merged commit f7e890d into nestjs:master Feb 6, 2023
@kamilmysliwiec
Copy link
Member

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants