UNPKG

@grapi/server

Version:

Grapi Schema Generator For GraphQL Server

92 lines (91 loc) 2.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const lodash_1 = require("../lodash"); const type_1 = require("./type"); class Field { type; nonNull; list; nonNullItem; unique; readOnly; autoGen; createdAt; updatedAt; metadata = {}; constructor({ type, nonNull, list, nonNullItem, unique, readOnly, autoGen, createdAt, updatedAt, }) { this.type = type; this.nonNull = (0, lodash_1.defaultTo)(nonNull, false); this.list = (0, lodash_1.defaultTo)(list, false); this.nonNullItem = (0, lodash_1.defaultTo)(nonNullItem, false); this.unique = (0, lodash_1.defaultTo)(unique, false); this.readOnly = (0, lodash_1.defaultTo)(readOnly, false); this.autoGen = (0, lodash_1.defaultTo)(autoGen, false); this.createdAt = (0, lodash_1.defaultTo)(createdAt, false); this.updatedAt = (0, lodash_1.defaultTo)(updatedAt, false); } isNonNull() { return this.nonNull; } setNonNull(value) { this.nonNull = value; } isNonNullItem() { return this.nonNullItem; } setNonNullItem(value) { this.nonNullItem = value; } isList() { return this.list; } setList(value) { this.list = value; } setUnique(value) { this.unique = value; } isUnique() { return this.unique; } isReadOnly() { return this.readOnly; } setReadOnly(value) { this.readOnly = value; } isAutoGenerated() { return this.autoGen; } setAutoGen(value) { this.autoGen = value; } getType() { return this.type; } isScalar() { return (0, type_1.isScalarType)(this.type); } getTypename() { return this.type.toString(); } getMetadata(key) { return this.metadata[key]; } setMetadata(key, value) { return this.metadata[key] = value; } isCreatedAt() { return this.createdAt; } setCreatedAt(value) { this.createdAt = value; } isUpdatedAt() { return this.updatedAt; } setUpdatedAt(value) { this.updatedAt = value; } } exports.default = Field;