Skip to content

Guards, Interceptors, Filters, Custom param decorators

Davide Gheri edited this page Feb 19, 2021 · 1 revision

nestjs-mercurius supports all the features descirbed here out of the box, the only diffenrence is which GqlExecutionContext use.

Instead of importing GqlExecutionContext from @nestjs/graphql, import from nestjs-mercurius

import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import { GqlExecutionContext } from 'nestjs-mercurius'; // THIS

export const User = createParamDecorator(
  (name: string, ctx: ExecutionContext) => {
    return GqlExecutionContext.create(ctx).getContext().user;
  },
);

This enables the usage of Guards, Interceptors, Filters and custom ParamDecorators on ResolveLoaders