UNPKG

800 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var graphql_anywhere_1 = require("graphql-anywhere");
4var gql_1 = require("./gql");
5function 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}
16exports.filter = filter;
17function 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}
25exports.default = reshape;
26//# sourceMappingURL=reshape.js.map
\No newline at end of file