Entity named Subscription breaks ResolveProperty
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 naming an entity Subscription all services and decorated parameters are undefined.
@Resolver(of => Subscription)
export class SubscriptionResolver {
constructor(private readonly subscriptionService: SubscriptionService) {}
@ResolveProperty('child')
child(@Root() subscription: Subscription): string {
console.log(this, subscription); // subscription and this.subscriptionService is undefined
return this.subscriptionService.getTest(); // Cannot read property 'getTest' of undefined
}
}
Expected behavior
The values shouldn't be undefined
Minimal reproduction of the problem with instructions
- Git Repo: https://github.com/raydirty/nestjs-resolver-bug
Environment
platform-express version : 6.9.0
graphql version : 6.5.3
common version : 6.9.0
core version : 6.9.0
I am actually experiencing this issue with any use case for ResolveProperty.
UPDATE
Mine is a different issue.
For any poor sole spending an entire day debugging make sure you import the Resolver annotation from @nestjs/graphql and not from type-graphql. 😩
Aside from this issue, what's the reason for naming any object type "Subscription". Isn't it going to create a lot of confusion (and potential type collisions in the generated GraphQL schema?)
I had the same problem here (and it was hard to discover what was going on).
So I think it would be good to have a Note on the docs alerting for that.
What do you think guys?
ps: it might happen with Query, Mutation and so on.
Creating an object type called either Subscription, Query, or Mutation will surely lead to errors because they collide with GraphQL operation types.