Usage of @ResolvePoperty() causes multiple instantiations of resolver
See original GitHub issueI’m submitting a…
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
When a @ResolveProperty()
function gets executed and a request scoped service was injected into the resolver a new instance of a resolver gets created each time a @ResolveProperty()
function gets executed.
Expected behavior
Only one instance of the resolver and the service get created per request.
Minimal reproduction of the problem with instructions
https://github.com/xXKeyleXx/graphql-minimal-resolve-property
Execute the following query and watch the console output.
query {
getTestsByIds(ids: ["1","2","3","4"]) {
id
parent {
id
}
}
}
Comment out the property resolver and it works like expected.
What is the motivation / use case for changing the behavior?
If a new instance of a dataloader gets created each time a property gets resolved it defeates the purpose of the dataloader 😅
Environment
@nestjs/common: 6.2.4,
@nestjs/core: 6.2.4,
@nestjs/graphql: 6.2.1,
apollo-server-express: 2.5.0
type-graphql: 0.17.4
graphql: 14.3.0
For Tooling issues:
- Node version: v10.15.3
- Platform: Linux (Docker) / Windows
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Resolvers - Apollo GraphQL Docs
A resolver is a function that's responsible for populating the data for a single field in your schema. It can populate that data...
Read more >nestjs - Nested field resolvers in GraphQL - Stack Overflow
A) Is there a way to use PetResolver within UserResolver to make use of the individual field resolution logic? B) If not, what...
Read more >Resolvers - TypeGraphQL
First we create the resolver class and annotate it with the @Resolver() ... we shouldn't use them there, as TypeGraphQL creates instances of...
Read more >Resolvers | NestJS - A progressive Node.js framework
The @nestjs/graphql package, on the other hand, generates a resolver map ... To specify that the method is a query handler, use the...
Read more >GraphQL subscriptions with Nest: how to publish across ...
It only informs Nest that each @ResolveProperty() inside this ... how to use Redis and GQL subscriptions to publish events across multiple ......
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
Fix published as 6.2.3
It sounds more like a circular dependency issue in your code.