UNPKG

@pothos/core

Version:

Pothos (formerly GiraphQL) is a plugin based schema builder for creating code-first GraphQL schemas in typescript

57 lines (56 loc) 1.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "FieldRef", { enumerable: true, get: function() { return FieldRef; } }); const _types = require("../types"); function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } let _outputFieldShapeKey = _types.outputFieldShapeKey; class FieldRef { updateConfig(cb) { this.pendingActions.push(cb); } getConfig(name, typeConfig) { const config = this.pendingActions.reduce((cfg, cb)=>{ var _cb; return (_cb = cb(cfg)) !== null && _cb !== void 0 ? _cb : cfg; }, this.initConfig(name, typeConfig)); for (const cb of this.onUseCallbacks){ this.onUseCallbacks.delete(cb); cb(config); } return config; } onFirstUse(cb) { this.onUseCallbacks.add(cb); } constructor(kind, initConfig){ _define_property(this, "kind", void 0); _define_property(this, "fieldName", void 0); _define_property(this, "$inferType", void 0); _define_property(this, _outputFieldShapeKey, void 0); _define_property(this, "pendingActions", []); _define_property(this, "initConfig", void 0); _define_property(this, "onUseCallbacks", new Set()); this.kind = kind; this.initConfig = initConfig; } } //# sourceMappingURL=field.js.map