1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var graphql_anywhere_1 = require("graphql-anywhere");
|
4 | var gql_1 = require("./gql");
|
5 | function filter(doc, data) {
|
6 | var resolver = function (fieldName, root, args, context, info) {
|
7 | if (root.hasOwnProperty(fieldName)) {
|
8 | return root[fieldName];
|
9 | }
|
10 | else {
|
11 | return root[info.resultKey];
|
12 | }
|
13 | };
|
14 | return graphql_anywhere_1.default(resolver, doc, data);
|
15 | }
|
16 | exports.filter = filter;
|
17 | function reshape(doc, data) {
|
18 | var _a = gql_1.graphqlLodash(doc), transform = _a.transform, apply = _a.apply;
|
19 | var result = filter(doc, data);
|
20 | if (apply) {
|
21 | return transform(result);
|
22 | }
|
23 | return result;
|
24 | }
|
25 | exports.default = reshape;
|
26 |
|
\ | No newline at end of file |