refactor: refactored gql-user-decorator to work for subscriptions

This commit is contained in:
Balu Babu
2023-02-08 14:23:27 +05:30
parent 965fdad8b1
commit 9c64721bf0

View File

@@ -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;
},
);