UNPKG

1.72 kBJavaScriptView Raw
1"use strict";
2var __rest = (this && this.__rest) || function (s, e) {
3 var t = {};
4 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5 t[p] = s[p];
6 if (s != null && typeof Object.getOwnPropertySymbols === "function")
7 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9 t[p[i]] = s[p[i]];
10 }
11 return t;
12};
13Object.defineProperty(exports, "__esModule", { value: true });
14exports.CustomField = void 0;
15var type_graphql_1 = require("type-graphql");
16var typeorm_1 = require("typeorm");
17var schema_1 = require("../schema");
18var utils_1 = require("../utils");
19var WarthogField_1 = require("./WarthogField");
20function CustomField(args) {
21 // const nullableOption = typeof args.nullable !== 'undefined' ? { nullable: args.nullable } : {};
22 // const dbOptions = { ...nullableOption, ...(args.db || {}) };
23 var _a = args.api, type = _a.type, filter = _a.filter, sort = _a.sort, typeGraphQLOptions = __rest(_a, ["type", "filter", "sort"]);
24 var warthogOptions = { nullable: args.api.nullable, type: type, filter: filter, sort: sort };
25 // These are the 2 required decorators to get type-graphql and typeorm working
26 var factories = [
27 WarthogField_1.WarthogField(args.api.type, warthogOptions),
28 type_graphql_1.Field(function () { return schema_1.columnTypeToGraphQLType(args.api.type); }, typeGraphQLOptions),
29 typeorm_1.Column(args.db)
30 ];
31 return utils_1.composeMethodDecorators.apply(void 0, factories);
32}
33exports.CustomField = CustomField;
34//# sourceMappingURL=CustomField.js.map
\No newline at end of file