-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphQLHelper.js
executable file
·31 lines (24 loc) · 1.04 KB
/
graphQLHelper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildQuery = exports.buildArgs = exports.buildArgDefinitions = undefined;
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var buildArgDefinitions = exports.buildArgDefinitions = function buildArgDefinitions(args) {
return (0, _keys2.default)(args).map(function (arg) {
return '$' + arg + ': ' + args[arg];
}).join(',');
};
var buildArgs = exports.buildArgs = function buildArgs(args) {
return (0, _keys2.default)(args).map(function (arg) {
return arg + ': $' + arg;
}).join(',');
};
var buildQuery = exports.buildQuery = function buildQuery(_ref) {
var queryRoot = _ref.queryRoot,
args = _ref.args,
query = _ref.query;
return '\nquery(' + buildArgDefinitions(args) + ') {\n ' + queryRoot + '(' + buildArgs(args) + ') {\n ' + query + '\n }\n}';
};