UNPKG

@pothos/core

Version:

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

50 lines (49 loc) 1.54 kB
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; } import { inputFieldShapeKey } from '../types/index.js'; let _inputFieldShapeKey = inputFieldShapeKey; export class ArgumentRef { onConfig(cb) { this.pendingActions.push(cb); } updateConfig(cb) { this.pendingActions.push(cb); } getConfig(name, field, typeConfig) { const config = this.pendingActions.reduce((config, cb) => { var _cb; return (_cb = cb(config)) !== null && _cb !== void 0 ? _cb : config; }, this.initConfig(name, field, typeConfig)); for (const cb of this.onUseCallbacks) { this.onUseCallbacks.delete(cb); cb(config); } return config; } onFirstUse(cb) { this.onUseCallbacks.add(cb); } constructor(initConfig) { _define_property(this, "kind", "Arg"); _define_property(this, "fieldName", void 0); _define_property(this, "$inferInput", void 0); _define_property(this, _inputFieldShapeKey, void 0); _define_property(this, "pendingActions", []); _define_property(this, "initConfig", void 0); _define_property(this, "onUseCallbacks", new Set()); this.initConfig = initConfig; } } //# sourceMappingURL=arg.js.map