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.

GraphQLExecutionContext does not inherits methods from ExecutionContext

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

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kamilmysliwieccommented, Jan 8, 2020

It should be fixed in 6.5.4 😃 Let me know if you face any issues

0reactions
lock[bot]commented, Apr 25, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ExecutionContext (graphql-java 12.0 API) - javadoc.io
This method will allow you to add errors into the running execution context, without a check for per field unique-ness. void, addError(GraphQLError error, ......
Read more >
Execution context | NestJS - A progressive Node.js framework
To retrieve the array of arguments being passed to the handler, one approach is to use the host object's getArgs() method. const [req,...
Read more >
In the Graphql I need to display list - Stack Overflow
Assuming that infoService.GetPatientById() returns a list the following change will reflect that in the resolver. This line:
Read more >
Migrating from v3.x to v4.x - GraphQL .NET
GraphQL.NET will not receive new dependencies, since all methods just read or write meta information. ... With the addition of ExecutionContext.
Read more >
Fields (Unmounted Types) - Graphene-Python
Most of the time this method will be called by one of the Graphene Integrations ... as defined in graphql-core . execution_context_class (ExecutionContext, ......
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