graphql icon indicating copy to clipboard operation
graphql copied to clipboard

GraphQL context not correct in Guards when __resolveType handler is called

Open JannesV opened this issue 7 years ago • 6 comments

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 in a resolveType handler the context is wrongly resolved. Which makes me unable to use the graphql context in an global guard.

Expected behavior

Context to be resolved correctly

Minimal reproduction of the problem with instructions

https://github.com/JannesV/nestjs-issue-context

What is the motivation / use case for changing the behavior?

Need to use global guards

Environment


Nest version: 6.0.5

 
For Tooling issues:
- Node version: 8.11.4 \ 10.0  
- Platform:  Mac\ Linux

JannesV avatar Apr 09 '19 14:04 JannesV

I also faced this problem. It's because arguments passed to resolvers by apollo-server are different on field resolvers and __resolveType. https://www.apollographql.com/docs/graphql-tools/resolvers

But at first place, I can't understand why guard should be applied on __resolveType method. Is there any reason for this? @kamilmysliwiec

Hossein-s avatar Apr 24 '19 09:04 Hossein-s

@kamilmysliwiec if you could point me in the right direction I'll gladly submit a PR.

JannesV avatar May 07 '19 13:05 JannesV

It should be fixed in the @next version ($ npm i @nestjs/graphql@next). You will also have to update @nestjs/core to 6.2.0 ($ npm i @nestjs/[email protected]). Please, let me know if you face any issue.

kamilmysliwiec avatar May 11 '19 12:05 kamilmysliwiec

Published as 6.2.0 ($ npm i @nestjs/graphql@latest). You will also have to update @nestjs/core to 6.2.0 ($ npm i @nestjs/core@latest)

kamilmysliwiec avatar May 14 '19 09:05 kamilmysliwiec

Indeed it works, thank a lot for the work you're doing!

JannesV avatar Jun 03 '19 06:06 JannesV

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Apr 25 '20 10:04 lock[bot]