UNPKG

@nestjs/graphql

Version:

Nest - modern, fast, powerful node.js web framework (@graphql)

60 lines (59 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ResolverDecoratorHost = void 0; const tslib_1 = require("tslib"); const common_1 = require("@nestjs/common"); /** * @publicApi */ let ResolverDecoratorHost = class ResolverDecoratorHost { setDecorator(decorator) { this.decorator = decorator; } getDecorator() { return this.decorator; } decorate(target) { if (!this.decorator) { return target; } return this.decorator(target); } /** * Registers a hook that is called right before a GraphQL operation * starts being processed. Whatever it returns is passed back to the * "request end" hook through the `state` property. */ setOnRequestStartHook(hook) { this.onRequestStartHook = hook; } getOnRequestStartHook() { return this.onRequestStartHook; } /** * Registers a hook that is called once a GraphQL operation has been * fully processed (right before the response is sent back to the client). */ setOnRequestEndHook(hook) { this.onRequestEndHook = hook; } getOnRequestEndHook() { return this.onRequestEndHook; } /** * Indicates whether any of the request lifecycle hooks has been registered. */ hasRequestHooks() { return !!(this.onRequestStartHook || this.onRequestEndHook); } onRequestStart(context) { return this.onRequestStartHook?.(context); } onRequestEnd(context) { this.onRequestEndHook?.(context); } }; exports.ResolverDecoratorHost = ResolverDecoratorHost; exports.ResolverDecoratorHost = ResolverDecoratorHost = tslib_1.__decorate([ (0, common_1.Injectable)() ], ResolverDecoratorHost);