@pothos/core
Version:
Pothos (formerly GiraphQL) is a plugin based schema builder for creating code-first GraphQL schemas in typescript
54 lines (53 loc) • 1.67 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 { inputShapeKey } from '../types/index.js';
import { BaseTypeRef } from './base.js';
let _inputShapeKey = inputShapeKey;
export class InputObjectRef extends BaseTypeRef {
addFields(fields) {
this.fields.add(fields);
for (const cb of this.fieldCbs) {
for (const [name, ref] of Object.entries(fields())) {
if (ref) {
cb(name, ref);
}
}
}
}
onField(cb) {
this.fieldCbs.add(cb);
for (const fieldMap of this.fields) {
for (const [name, ref] of Object.entries(fieldMap())) {
if (ref) {
cb(name, ref);
}
}
}
}
constructor(name) {
super("InputObject", name), _define_property(this, "kind", "InputObject"), _define_property(this, "$inferInput", void 0), _define_property(this, _inputShapeKey, void 0), _define_property(this, "fields", new Set()), _define_property(this, "fieldCbs", new Set());
}
}
export class ImplementableInputObjectRef extends InputObjectRef {
implement(options) {
this.builder.inputType(this, options);
return this;
}
constructor(builder, name) {
super(name), _define_property(this, "builder", void 0);
this.builder = builder;
}
}
//# sourceMappingURL=input-object.js.map