UNPKG

@pothos/core

Version:

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

153 lines (152 loc) 4.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "RootFieldBuilder", { enumerable: true, get: function() { return RootFieldBuilder; } }); const _list = require("../refs/list"); const _base = require("./base"); const _input = require("./input"); 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; } class RootFieldBuilder extends _base.BaseFieldUtil { /** * Create a Boolean field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ boolean(...args) { const [options = {}] = args; return this.createField({ ...options, type: 'Boolean' }); } /** * Create a Float field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ float(...args) { const [options = {}] = args; return this.createField({ ...options, type: 'Float' }); } /** * Create a ID field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ id(...args) { const [options = {}] = args; return this.createField({ ...options, type: 'ID' }); } /** * Create a Int field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ int(...args) { const [options = {}] = args; return this.createField({ ...options, type: 'Int' }); } /** * Create a String field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ string(...args) { const [options = {}] = args; return this.createField({ ...options, type: 'String' }); } /** * Create a Boolean list field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ booleanList(...args) { const [options = {}] = args; return this.createField({ ...options, type: [ 'Boolean' ] }); } /** * Create a Float list field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ floatList(...args) { const [options = {}] = args; return this.createField({ ...options, type: [ 'Float' ] }); } /** * Create a ID list field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ idList(...args) { const [options = {}] = args; return this.createField({ ...options, type: [ 'ID' ] }); } /** * Create a Int list field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ intList(...args) { const [options = {}] = args; return this.createField({ ...options, type: [ 'Int' ] }); } /** * Create a String list field * @param {PothosSchemaTypes.FieldOptions} options - Options for this field */ stringList(...args) { const [options = {}] = args; return this.createField({ ...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 _list.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 _input.InputFieldBuilder(this.builder, 'Arg').argBuilder()); } } //# sourceMappingURL=root.js.map