import { ExecutionContext , Injectable } from '@nestjs/common' ; import { GqlContextType , GqlExecutionContext } from '@nestjs/graphql' ; import { AuthGuard } from '@nestjs/passport' ; import type { Request } from 'express' ; @ Injectable ( ) export class JwtAuthGuard extends AuthGuard ( 'jwt' ) { public getRequest ( context ) { if ( context . getType < GqlContextType > ( ) === 'graphql' ) { const ctx = GqlExecutionContext . create ( context ) . getContext ( ) ; return < Request > ctx . req ; } return context . switchToHttp ( ) . getRequest < Request > ( ) ; } }