question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage of @ResolvePoperty() causes multiple instantiations of resolver

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kamilmysliwieccommented, Jun 5, 2019

Fix published as 6.2.3

1reaction
kamilmysliwieccommented, May 30, 2019

It sounds more like a circular dependency issue in your code.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found