UNPKG

@pothos/core

Version:

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

154 lines (153 loc) 4.38 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 { ListRef } from '../refs/list.js'; import { BaseFieldUtil } from './base.js'; import { InputFieldBuilder } from './input.js'; export class RootFieldBuilder extends BaseFieldUtil { /** * Create a Boolean field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ boolean(...args) { const [options = {}] = args; return this.createField({ resolve: undefined, ...options, type: "Boolean" }); } /** * Create a Float field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ float(...args) { const [options = {}] = args; return this.createField({ resolve: undefined, ...options, type: "Float" }); } /** * Create a ID field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ id(...args) { const [options = {}] = args; return this.createField({ resolve: undefined, ...options, type: "ID" }); } /** * Create a Int field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ int(...args) { const [options = {}] = args; return this.createField({ resolve: undefined, ...options, type: "Int" }); } /** * Create a String field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ string(...args) { const [options = {}] = args; return this.createField({ resolve: undefined, ...options, type: "String" }); } /** * Create a Boolean list field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ booleanList(...args) { const [options = {}] = args; return this.createField({ resolve: undefined, ...options, type: [ "Boolean" ] }); } /** * Create a Float list field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ floatList(...args) { const [options = {}] = args; return this.createField({ resolve: undefined, ...options, type: [ "Float" ] }); } /** * Create a ID list field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ idList(...args) { const [options = {}] = args; return this.createField({ resolve: undefined, ...options, type: [ "ID" ] }); } /** * Create a Int list field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ intList(...args) { const [options = {}] = args; return this.createField({ resolve: undefined, ...options, type: [ "Int" ] }); } /** * Create a String list field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ stringList(...args) { const [options = {}] = args; return this.createField({ resolve: undefined, ...options, type: [ "String" ] }); } /** * create a new field for the current type * @param {PothosSchemaTypes.FieldOptions} options - options for this field */ field(options) { return this.createField(options); } listRef(type, options) { var _options_nullable; return new ListRef(type, (_options_nullable = options === null || options === void 0 ? void 0 : options.nullable) !== null && _options_nullable !== void 0 ? _options_nullable : false); } constructor(...args) { super(...args), _define_property(this, "arg", new InputFieldBuilder(this.builder, "Arg").argBuilder()); } } //# sourceMappingURL=root.js.map