@pothos/core
Version:
Pothos (formerly GiraphQL) is a plugin based schema builder for creating code-first GraphQL schemas in typescript
59 lines (58 loc) • 1.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "ArgumentRef", {
enumerable: true,
get: function() {
return ArgumentRef;
}
});
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 _inputFieldShapeKey = _types.inputFieldShapeKey;
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