@nestjs/graphql
Version:
Nest - modern, fast, powerful node.js web framework (@graphql)
57 lines (56 loc) • 1.59 kB
JavaScript
import { __decorate } from "tslib";
import { Injectable } from '@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);
}
};
ResolverDecoratorHost = __decorate([
Injectable()
], ResolverDecoratorHost);
export { ResolverDecoratorHost };