-
Notifications
You must be signed in to change notification settings - Fork 402
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
Resolver metadata cache returns wrong results #1907
Comments
Would you like to create a PR to address this issue? |
Yeah I could give it a try |
🏓 🙌 |
Was this issue ever resolved? We're observing similar behavior where resolvers overlap in a nestjs app with multiple graphql endpoints. Renaming the offending resolvers fixed the issue. Let us know if a fix is planned otherwise we'd be willing to open a PR! |
I'm sorry I can't fix this now. It was side project and I currently don't have time for it. If you can open a PR, please do. Thanks |
@kamilmysliwiec, I started looking into this issue and the fix proposed is too broad, IMHO. What it means is that every single provider will get a Another way we could approach this is to add a method called, say, A slightly different take might be to pass an extra argument (say, These, IMHO, would be cleaner ways of proceeding but would require two sets of changes — one to NestJS core, and the other to the I'm happy to make PRs for these but want to check with you if this is a good approach or there's something else I'm missing. |
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
Let's track this here #1907 |
Is there an existing issue for this?
Current behavior
When using two equally named resolvers even when they are in diffrent modules, and both have equally named methods, Args decorator doesnt propagate data into the last one.
Minimum reproduction code
https://github.com/jakubnavratil/nestjs-resolvers-bug
Steps to reproduce
npm i
npm run start
open http://localhost:3000/graphql
run both, B fails
Expected behavior
Works without need to make unique methods name across multiple modules.
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
No response
Packages versions
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"@nestjs/graphql": "^9.1.2",
Node.js version
No response
In which operating systems have you tested?
Other
It comes down to this commit nestjs/nest@035348e
which fixes this nestjs/nest#3231 and introduced uniquely generated ID for controllers but doesnt do that for Resolvers (providers)
This ID is then used here https://github.com/nestjs/nest/blob/master/packages/core/helpers/handler-metadata-storage.ts#L62
but if it is missing, it uses class name to generate keys.
Hence both
login
methods in my example has same keys.I believe this should be fixed by adding this line
before this line https://github.com/nestjs/nest/blob/master/packages/core/injector/module.ts#L240
At least, this works for me in fairly large app.
The text was updated successfully, but these errors were encountered: