Skip to content
Davide Gheri edited this page Feb 23, 2021 · 1 revision

Mercurius expose few hooks allowing you to listen to specific events in the GraphQL request/response lifecycle.

Hooks are registered as method decorated with the @GraphQLHook(hookName: string) decorator, for a list of all available hooks, please see Mercurius documentation

Example

import { GraphQLHook } from 'nestjs-mercurius';

@Injectable()
export class HookService {
  @GraphQLHook('preValidation')
  async onPreValidation(schema: GraphQLSchema, source: DocumentNode, context: any) {
   //...
  }
}