1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.default = void 0;
|
9 |
|
10 | var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
11 |
|
12 | var _objectSpread2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectSpread"));
|
13 |
|
14 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
15 |
|
16 | var _spread = _interopRequireDefault(require("@sharyn/util/spread"));
|
17 |
|
18 | var _call = _interopRequireDefault(require("./call"));
|
19 |
|
20 |
|
21 | var graphqlCall =
|
22 |
|
23 | function () {
|
24 | var _ref2 = (0, _asyncToGenerator2.default)(
|
25 |
|
26 | _regenerator.default.mark(function _callee(_ref) {
|
27 | var _callResp, _callResp$data, _callResp2, _callResp2$data, _callResp3, _callResp3$data;
|
28 |
|
29 | var urlBase, query, variables, mapResp, cookie, callResp, _err$response, _err$response$data;
|
30 |
|
31 | return _regenerator.default.wrap(function _callee$(_context) {
|
32 | while (1) {
|
33 | switch (_context.prev = _context.next) {
|
34 | case 0:
|
35 | urlBase = _ref.urlBase, query = _ref.query, variables = _ref.variables, mapResp = _ref.mapResp, cookie = _ref.cookie;
|
36 | _context.prev = 1;
|
37 | _context.next = 4;
|
38 | return (0, _call.default)({
|
39 | urlBase: urlBase,
|
40 | cookie: cookie,
|
41 | body: {
|
42 | query: query,
|
43 | variables: variables
|
44 | }
|
45 | });
|
46 |
|
47 | case 4:
|
48 | callResp = _context.sent;
|
49 | _context.next = 10;
|
50 | break;
|
51 |
|
52 | case 7:
|
53 | _context.prev = 7;
|
54 | _context.t0 = _context["catch"](1);
|
55 | throw ((_err$response = _context.t0.response) === null || _err$response === void 0 ? void 0 : (_err$response$data = _err$response.data) === null || _err$response$data === void 0 ? void 0 : _err$response$data.errors) ? _context.t0.response.data.errors[0] : _context.t0;
|
56 |
|
57 | case 10:
|
58 | return _context.abrupt("return", (0, _objectSpread2.default)({}, (0, _spread.default)({
|
59 | errors: (_callResp = callResp) === null || _callResp === void 0 ? void 0 : (_callResp$data = _callResp.data) === null || _callResp$data === void 0 ? void 0 : _callResp$data.errors
|
60 | }), mapResp ? mapResp((_callResp2 = callResp) === null || _callResp2 === void 0 ? void 0 : (_callResp2$data = _callResp2.data) === null || _callResp2$data === void 0 ? void 0 : _callResp2$data.data) : (_callResp3 = callResp) === null || _callResp3 === void 0 ? void 0 : (_callResp3$data = _callResp3.data) === null || _callResp3$data === void 0 ? void 0 : _callResp3$data.data));
|
61 |
|
62 | case 11:
|
63 | case "end":
|
64 | return _context.stop();
|
65 | }
|
66 | }
|
67 | }, _callee, this, [[1, 7]]);
|
68 | }));
|
69 |
|
70 | return function graphqlCall(_x) {
|
71 | return _ref2.apply(this, arguments);
|
72 | };
|
73 | }();
|
74 |
|
75 | var _default = graphqlCall;
|
76 | exports.default = _default; |
\ | No newline at end of file |