@pothos/core
Version:
Pothos (formerly GiraphQL) is a plugin based schema builder for creating code-first GraphQL schemas in typescript
48 lines (47 loc) • 1.49 kB
JavaScript
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 { outputFieldShapeKey } from '../types/index.js';
let _outputFieldShapeKey = outputFieldShapeKey;
export 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