UNPKG

graphql-composer

Version:
47 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Wrapper = void 0; const __1 = require(".."); class Wrapper { constructor(...types) { this._types = []; this.setTypes(...types); } get types() { return this._types; } static create(...types) { const wrapper = new Wrapper(...types); return wrapper; } setTypes(...types) { this._types = types; return this; } addTypes(...types) { return this.setTypes(...this._types, ...types); } removeTypes(...types) { return this.setTypes(...__1.ArrayHelper.remove(types, this._types)); } addMiddlewares(...middlewares) { this.transformFields(__1.GQLObjectType, (f) => { f.addMiddlewares(...middlewares); }); } transform(toTransform, cb) { this._types.map((t) => { if (t instanceof toTransform) { cb(t); } }); return this; } transformFields(fieldType, cb) { return this.transform(fieldType, (f) => { f.fields.map(cb); }); } } exports.Wrapper = Wrapper; //# sourceMappingURL=Wrapper.js.map