chore: added gql decorator and complexity plugin
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
|
||||
import { User } from '../user/user.model';
|
||||
import { GqlExecutionContext } from '@nestjs/graphql';
|
||||
|
||||
export const GqlUser = createParamDecorator<any, any, User>(
|
||||
(_data: any, context: ExecutionContext) => {
|
||||
const { user } = GqlExecutionContext.create(context).getContext<{
|
||||
user: User;
|
||||
}>();
|
||||
if (!user)
|
||||
throw new Error(
|
||||
'@GqlUser decorator use with null user. Make sure the resolve has the @GqlAuthGuard present.',
|
||||
);
|
||||
|
||||
return user;
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user