UNPKG

graphql-composer

Version:
71 lines 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GQLField = void 0; const __1 = require("../.."); const GQLElement_1 = require("../../classes/GQLElement"); const Nullable_1 = require("../modifiers/Nullable"); class GQLField extends GQLElement_1.GQLElement { constructor(name, type) { super(name); this.setType(type); } get type() { return this._type; } get description() { return this._description; } get deprecationReason() { return this._deprecationReason; } /** * Set the field type * @param type the type of your field */ setType(type) { this._type = type; return this; } /** * Set the description of the field * @param deprecationReason The deprecation reason */ setDescription(description) { this._description = description; return this; } /** * Set the deprecation reason of the field * @param deprecationReason The deprecation reason */ setDeprecationReason(deprecationReason) { this._deprecationReason = deprecationReason; return this; } /** * Convert your field type into a nullable type */ nullable() { if (this.type instanceof __1.RequiredType) { this._type = this._type.type; } if (!(this.type instanceof Nullable_1.NullableType)) { this.setType(Nullable_1.Nullable(this._type)); } return this; } /** * Convert your field type into a not nullable type */ required() { if (this.type instanceof Nullable_1.NullableType) { this._type = this._type.type; } if (!(this.type instanceof __1.RequiredType)) { this.setType(__1.Required(this._type)); } return this; } } exports.GQLField = GQLField; //# sourceMappingURL=GQLField.js.map