From 9c64721bf03f1be1a947d3c99574b609058d9b4f Mon Sep 17 00:00:00 2001 From: Balu Babu Date: Wed, 8 Feb 2023 14:23:27 +0530 Subject: [PATCH] refactor: refactored gql-user-decorator to work for subscriptions --- .../hoppscotch-backend/src/decorators/gql-user.decorator.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hoppscotch-backend/src/decorators/gql-user.decorator.ts b/packages/hoppscotch-backend/src/decorators/gql-user.decorator.ts index 03c8fffe1..71042e069 100644 --- a/packages/hoppscotch-backend/src/decorators/gql-user.decorator.ts +++ b/packages/hoppscotch-backend/src/decorators/gql-user.decorator.ts @@ -4,7 +4,7 @@ import { GqlExecutionContext } from '@nestjs/graphql'; export const GqlUser = createParamDecorator( (data: unknown, context: ExecutionContext) => { const ctx = GqlExecutionContext.create(context); - return ctx.getContext().req.user; + const { req, headers } = ctx.getContext(); + return headers ? headers.user : req.user; }, ); -