GraphQLExecutionContext does not inherits methods from ExecutionContext
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
The interface GraphQLExecutionContext
implements ExecutionContext
that exposes some methods to work with the context, ex. getHandler()
and getClass()
, but the Object created with GqlExecutionContext.create()
does not really include them.
I think it is because the create()
method just do an Object.assign that does not copy the host.__proto__
, thus forgetting about all the ExecutionContextHost.prototype
methods.
Now, to access the above mentioned methods I need to call the ExecutionContextHost directly.
Given that, the current GraphQLExecutionContext
interface implementation is wrong.
Expected behavior
It would be nice to have all the ExecutionContext
methods in GraphQLExecutionContext
, so I don’t have to keep track of the original ExecutionContext to call the other methods
Minimal reproduction of the problem with instructions
Just try to call one of the ExecutionContext
methods from the returned object of GqlExecutionContext.create(context)
...
canActivate(context: ExecutionContext) {
const gqlContext = GqlExecutionContext.create(context);
const handler = gqlContext.getHandler() //TypeError: gqlContext.getHandler is not a function
const classRef = gqlContext.getClass() //TypeError: gqlContext.getClass is not a function
const httpArgHost = gqlContext.switchToHttp() // TypeError: gqlContext.switchToHttp is not a function
}
Environment
Nest version: 6.7.2
Nest graphql version: 6.5.3
For Tooling issues:
- Node version: v12.13.1
- Platform: Mac
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
It should be fixed in 6.5.4 😃 Let me know if you face any issues
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.