13 lines
416 B
TypeScript
13 lines
416 B
TypeScript
import { Injectable, ExecutionContext } from '@nestjs/common';
|
|
import { GqlExecutionContext } from '@nestjs/graphql';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
|
|
@Injectable()
|
|
export class GqlAuthGuard extends AuthGuard('jwt') {
|
|
getRequest(context: ExecutionContext) {
|
|
const ctx = GqlExecutionContext.create(context);
|
|
const { req, headers } = ctx.getContext();
|
|
return headers ? headers : req;
|
|
}
|
|
}
|