UNPKG

graphql-composer

Version:
61 lines 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Arg = void 0; const __1 = require("../.."); const GQLField_1 = require("./GQLField"); class Arg extends GQLField_1.GQLField { constructor(name, type) { super(name, type); } get type() { return this._type; } get definitionNode() { return { name: { kind: "Name", value: this.name, }, kind: "InputValueDefinition", description: { kind: "StringValue", value: this.description, }, type: { kind: "NamedType", name: { kind: "Name", value: __1.TypeParser.parse(this.type).toString(), }, }, directives: this.directives.map((d) => d.definitionNode), }; } static create(nameOrField, type) { if (typeof nameOrField === "string") { return new Arg(nameOrField, type); } else if (nameOrField instanceof GQLField_1.GQLField) { return Arg.create(nameOrField.name, nameOrField.type) .setDescription(nameOrField.description) .setExtensions(nameOrField.extensions) .setDirectives(...nameOrField.directives) .setDeprecationReason(nameOrField.deprecationReason); } } build() { return { name: this._name, type: __1.TypeParser.parse(this._type, __1.Schema.config.requiredByDefault, __1.Schema.config.arrayRequired), description: this._description, defaultValue: this._defaultValue, astNode: undefined, extensions: this.extensions, }; } copy() { return Arg.create(this); } } exports.Arg = Arg; //# sourceMappingURL=Arg.js.map