UNPKG

@pothos/core

Version:

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

71 lines (70 loc) 2.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get }); } _export(exports, { get ImplementableInputObjectRef () { return ImplementableInputObjectRef; }, get InputObjectRef () { return InputObjectRef; } }); const _types = require("../types"); const _base = require("./base"); 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 _inputShapeKey = _types.inputShapeKey; class InputObjectRef extends _base.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()); } } 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