Resolver Guards: Cannot get request data 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
executionContext.switchToHttp().getRequest()
inside Guard return null, when I hit resolver using Graphiql (GraphQL IDE)
Expected behavior
executionContext.switchToHttp().getRequest()
should return http request data
Minimal reproduction of the problem with instructions
@Injectable()
export class RolesGuard implements CanActivate {
constructor(
private readonly reflector: Reflector,
) {}
async canActivate(context: ExecutionContext): Promise<boolean> {
try {
const request = context.switchToHttp().getRequest();
Environment
Nest version: 5.3.6
For Tooling issues:
- Node version: v10.9.0
- Platform: MAC
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Execution context | NestJS - A progressive Node.js framework
ExecutionContext class The getHandler() method returns a reference to the handler about to be invoked. The getClass() method returns the type of the...
Read more >unable to get cookies from ExecutionContext - Stack Overflow
I wanted to apply Guard only to a specific Resolver, so I used UseGuard instead of global middleware. Did my approach go wrong?...
Read more >cannot set headers after they are sent to the client nestjs
The error "Error: Can't set headers after they are sent." means that you're already in the Body or Finished state, but some function...
Read more >Guards with HttpModule : r/Nestjs_framework - Reddit
Guys, I'm implementing a bff with Nestjs that communicates with an api made in java. Then I created this guard: export class JwtAuthGuard ......
Read more >Node.js v19.3.0 Documentation
require.cache; require.extensions; require.main; require.resolve(request[, ... Since Node.js 8.0.0, exposure of memory cannot occur because the data is ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
While closed, the documentation isn’t great. There is nothing the explains what you’ll get back from getContext() of a GqlExecutionContext.
@WonderPanda see https://docs.nestjs.com/techniques/authentication GraphQL (there is an example how to achieve that)