1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.NestedFields = exports.Fields = void 0;
|
4 | var graphqlFields = require("graphql-fields");
|
5 | var type_graphql_1 = require("type-graphql");
|
6 | function Fields() {
|
7 | return type_graphql_1.createParamDecorator(function (_a) {
|
8 | var info = _a.info;
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | var rawFields = graphqlFields(info);
|
16 | var scalars = Object.keys(rawFields).filter(function (item) {
|
17 | return Object.keys(rawFields[item]).length === 0 && !item.startsWith('__');
|
18 | });
|
19 | return scalars;
|
20 | });
|
21 | }
|
22 | exports.Fields = Fields;
|
23 | function NestedFields() {
|
24 | return type_graphql_1.createParamDecorator(function (_a) {
|
25 | var info = _a.info;
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | var rawFields = graphqlFields(info);
|
33 | var output = { scalars: [] };
|
34 | var _loop_1 = function (fieldKey) {
|
35 | if (Object.keys(rawFields[fieldKey]).length === 0) {
|
36 | output.scalars.push(fieldKey);
|
37 | }
|
38 | else {
|
39 | var subFields_1 = rawFields[fieldKey];
|
40 | output[fieldKey] = Object.keys(subFields_1).filter(function (subKey) {
|
41 | return Object.keys(subFields_1[subKey]).length === 0;
|
42 | });
|
43 | }
|
44 | };
|
45 | for (var fieldKey in rawFields) {
|
46 | _loop_1(fieldKey);
|
47 | }
|
48 | return output;
|
49 | });
|
50 | }
|
51 | exports.NestedFields = NestedFields;
|
52 |
|
\ | No newline at end of file |