@avantstay/graphql-ts-client 10.5.0 → 10.6.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@ yarn add graphql-ts-client
13
13
  ### Generate the client
14
14
 
15
15
  ```typescript
16
- import { generateTypescriptClient } from 'graphql-ts-client'
16
+ import { generateTypescriptClient } from '@avantstay/graphql-ts-client'
17
17
 
18
18
  generateTypescriptClient({
19
19
  output: './myAwesomeApi.ts',
package/dist/endpoint.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
- function _array_like_to_array(arr, len) {
2
+ function _arrayLikeToArray(arr, len) {
3
3
  if (len == null || len > arr.length) len = arr.length;
4
4
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
5
  return arr2;
6
6
  }
7
- function _array_with_holes(arr) {
7
+ function _arrayWithHoles(arr) {
8
8
  if (Array.isArray(arr)) return arr;
9
9
  }
10
- function _assert_this_initialized(self) {
10
+ function _assertThisInitialized(self) {
11
11
  if (self === void 0) {
12
12
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
13
13
  }
@@ -27,7 +27,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
27
27
  Promise.resolve(value).then(_next, _throw);
28
28
  }
29
29
  }
30
- function _async_to_generator(fn) {
30
+ function _asyncToGenerator(fn) {
31
31
  return function() {
32
32
  var self = this, args = arguments;
33
33
  return new Promise(function(resolve, reject) {
@@ -42,23 +42,34 @@ function _async_to_generator(fn) {
42
42
  });
43
43
  };
44
44
  }
45
- function _class_call_check(instance, Constructor) {
45
+ function _classCallCheck(instance, Constructor) {
46
46
  if (!(instance instanceof Constructor)) {
47
47
  throw new TypeError("Cannot call a class as a function");
48
48
  }
49
49
  }
50
+ function isNativeReflectConstruct() {
51
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
52
+ if (Reflect.construct.sham) return false;
53
+ if (typeof Proxy === "function") return true;
54
+ try {
55
+ Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
56
+ return true;
57
+ } catch (e) {
58
+ return false;
59
+ }
60
+ }
50
61
  function _construct(Parent, args, Class) {
51
- if (_is_native_reflect_construct()) {
62
+ if (isNativeReflectConstruct()) {
52
63
  _construct = Reflect.construct;
53
64
  } else {
54
- _construct = function construct(Parent, args, Class) {
65
+ _construct = function _construct(Parent, args, Class) {
55
66
  var a = [
56
67
  null
57
68
  ];
58
69
  a.push.apply(a, args);
59
70
  var Constructor = Function.bind.apply(Parent, a);
60
71
  var instance = new Constructor();
61
- if (Class) _set_prototype_of(instance, Class.prototype);
72
+ if (Class) _setPrototypeOf(instance, Class.prototype);
62
73
  return instance;
63
74
  };
64
75
  }
@@ -73,12 +84,12 @@ function _defineProperties(target, props) {
73
84
  Object.defineProperty(target, descriptor.key, descriptor);
74
85
  }
75
86
  }
76
- function _create_class(Constructor, protoProps, staticProps) {
87
+ function _createClass(Constructor, protoProps, staticProps) {
77
88
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
78
89
  if (staticProps) _defineProperties(Constructor, staticProps);
79
90
  return Constructor;
80
91
  }
81
- function _define_property(obj, key, value) {
92
+ function _defineProperty(obj, key, value) {
82
93
  if (key in obj) {
83
94
  Object.defineProperty(obj, key, {
84
95
  value: value,
@@ -91,11 +102,11 @@ function _define_property(obj, key, value) {
91
102
  }
92
103
  return obj;
93
104
  }
94
- function _get_prototype_of(o) {
95
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
105
+ function _getPrototypeOf(o) {
106
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
96
107
  return o.__proto__ || Object.getPrototypeOf(o);
97
108
  };
98
- return _get_prototype_of(o);
109
+ return _getPrototypeOf(o);
99
110
  }
100
111
  function _inherits(subClass, superClass) {
101
112
  if (typeof superClass !== "function" && superClass !== null) {
@@ -108,12 +119,12 @@ function _inherits(subClass, superClass) {
108
119
  configurable: true
109
120
  }
110
121
  });
111
- if (superClass) _set_prototype_of(subClass, superClass);
122
+ if (superClass) _setPrototypeOf(subClass, superClass);
112
123
  }
113
- function _is_native_function(fn) {
124
+ function _isNativeFunction(fn) {
114
125
  return Function.toString.call(fn).indexOf("[native code]") !== -1;
115
126
  }
116
- function _iterable_to_array_limit(arr, i) {
127
+ function _iterableToArrayLimit(arr, i) {
117
128
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
118
129
  if (_i == null) return;
119
130
  var _arr = [];
@@ -137,10 +148,10 @@ function _iterable_to_array_limit(arr, i) {
137
148
  }
138
149
  return _arr;
139
150
  }
140
- function _non_iterable_rest() {
151
+ function _nonIterableRest() {
141
152
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
142
153
  }
143
- function _object_spread(target) {
154
+ function _objectSpread(target) {
144
155
  for(var i = 1; i < arguments.length; i++){
145
156
  var source = arguments[i] != null ? arguments[i] : {};
146
157
  var ownKeys = Object.keys(source);
@@ -150,7 +161,7 @@ function _object_spread(target) {
150
161
  }));
151
162
  }
152
163
  ownKeys.forEach(function(key) {
153
- _define_property(target, key, source[key]);
164
+ _defineProperty(target, key, source[key]);
154
165
  });
155
166
  }
156
167
  return target;
@@ -168,7 +179,7 @@ function ownKeys(object, enumerableOnly) {
168
179
  }
169
180
  return keys;
170
181
  }
171
- function _object_spread_props(target, source) {
182
+ function _objectSpreadProps(target, source) {
172
183
  source = source != null ? source : {};
173
184
  if (Object.getOwnPropertyDescriptors) {
174
185
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
@@ -179,38 +190,38 @@ function _object_spread_props(target, source) {
179
190
  }
180
191
  return target;
181
192
  }
182
- function _possible_constructor_return(self, call) {
183
- if (call && (_type_of(call) === "object" || typeof call === "function")) {
193
+ function _possibleConstructorReturn(self, call) {
194
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
184
195
  return call;
185
196
  }
186
- return _assert_this_initialized(self);
197
+ return _assertThisInitialized(self);
187
198
  }
188
- function _set_prototype_of(o, p) {
189
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
199
+ function _setPrototypeOf(o, p) {
200
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
190
201
  o.__proto__ = p;
191
202
  return o;
192
203
  };
193
- return _set_prototype_of(o, p);
204
+ return _setPrototypeOf(o, p);
194
205
  }
195
- function _sliced_to_array(arr, i) {
196
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
206
+ function _slicedToArray(arr, i) {
207
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
197
208
  }
198
- function _type_of(obj) {
209
+ var _typeof = function(obj) {
199
210
  "@swc/helpers - typeof";
200
211
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
201
- }
202
- function _unsupported_iterable_to_array(o, minLen) {
212
+ };
213
+ function _unsupportedIterableToArray(o, minLen) {
203
214
  if (!o) return;
204
- if (typeof o === "string") return _array_like_to_array(o, minLen);
215
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
205
216
  var n = Object.prototype.toString.call(o).slice(8, -1);
206
217
  if (n === "Object" && o.constructor) n = o.constructor.name;
207
218
  if (n === "Map" || n === "Set") return Array.from(n);
208
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
219
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
209
220
  }
210
- function _wrap_native_super(Class) {
221
+ function _wrapNativeSuper(Class) {
211
222
  var _cache = typeof Map === "function" ? new Map() : undefined;
212
- _wrap_native_super = function wrapNativeSuper(Class) {
213
- if (Class === null || !_is_native_function(Class)) return Class;
223
+ _wrapNativeSuper = function _wrapNativeSuper(Class) {
224
+ if (Class === null || !_isNativeFunction(Class)) return Class;
214
225
  if (typeof Class !== "function") {
215
226
  throw new TypeError("Super expression must either be null or a function");
216
227
  }
@@ -219,7 +230,7 @@ function _wrap_native_super(Class) {
219
230
  _cache.set(Class, Wrapper);
220
231
  }
221
232
  function Wrapper() {
222
- return _construct(Class, arguments, _get_prototype_of(this).constructor);
233
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
223
234
  }
224
235
  Wrapper.prototype = Object.create(Class.prototype, {
225
236
  constructor: {
@@ -229,11 +240,11 @@ function _wrap_native_super(Class) {
229
240
  configurable: true
230
241
  }
231
242
  });
232
- return _set_prototype_of(Wrapper, Class);
243
+ return _setPrototypeOf(Wrapper, Class);
233
244
  };
234
- return _wrap_native_super(Class);
245
+ return _wrapNativeSuper(Class);
235
246
  }
236
- function _is_native_reflect_construct() {
247
+ function _isNativeReflectConstruct() {
237
248
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
238
249
  if (Reflect.construct.sham) return false;
239
250
  if (typeof Proxy === "function") return true;
@@ -244,20 +255,20 @@ function _is_native_reflect_construct() {
244
255
  return false;
245
256
  }
246
257
  }
247
- function _create_super(Derived) {
248
- var hasNativeReflectConstruct = _is_native_reflect_construct();
258
+ function _createSuper(Derived) {
259
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
249
260
  return function _createSuperInternal() {
250
- var Super = _get_prototype_of(Derived), result;
261
+ var Super = _getPrototypeOf(Derived), result;
251
262
  if (hasNativeReflectConstruct) {
252
- var NewTarget = _get_prototype_of(this).constructor;
263
+ var NewTarget = _getPrototypeOf(this).constructor;
253
264
  result = Reflect.construct(Super, arguments, NewTarget);
254
265
  } else {
255
266
  result = Super.apply(this, arguments);
256
267
  }
257
- return _possible_constructor_return(this, result);
268
+ return _possibleConstructorReturn(this, result);
258
269
  };
259
270
  }
260
- function _ts_generator(thisArg, body) {
271
+ var __generator = this && this.__generator || function(thisArg, body) {
261
272
  var f, y, t, g, _ = {
262
273
  label: 0,
263
274
  sent: function() {
@@ -351,7 +362,7 @@ function _ts_generator(thisArg, body) {
351
362
  done: true
352
363
  };
353
364
  }
354
- }
365
+ };
355
366
  var __create = Object.create;
356
367
  var __defProp = Object.defineProperty;
357
368
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -396,11 +407,7 @@ var __copyProps = function(to, from, except, desc) {
396
407
  return to;
397
408
  };
398
409
  var __toESM = function(mod, isNodeMode, target) {
399
- return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
400
- // file that has been converted to a CommonJS file using a Babel-
401
- // compatible transform (i.e. "__esModule" has not been set), then set
402
- // "default" to the CommonJS "module.exports" for node compatibility.
403
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
410
+ return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
404
411
  value: mod,
405
412
  enumerable: true
406
413
  }) : target, mod);
@@ -423,17 +430,17 @@ var import_moize = __toESM(require("moize"));
423
430
  var import_axios = __toESM(require("axios"));
424
431
  // src/types.ts
425
432
  var GraphQLClientError = /*#__PURE__*/ function(Error1) {
426
- _inherits(_GraphQLClientError, Error1);
427
- var _super = _create_super(_GraphQLClientError);
428
- function _GraphQLClientError(responseData) {
429
- _class_call_check(this, _GraphQLClientError);
433
+ _inherits(GraphQLClientError1, Error1);
434
+ var _super = _createSuper(GraphQLClientError1);
435
+ function GraphQLClientError1(responseData) {
436
+ _classCallCheck(this, GraphQLClientError1);
430
437
  var _this;
431
438
  _this = _super.call(this);
432
439
  _this.responseData = responseData;
433
- Object.setPrototypeOf(_assert_this_initialized(_this), _GraphQLClientError.prototype);
440
+ Object.setPrototypeOf(_assertThisInitialized(_this), GraphQLClientError.prototype);
434
441
  return _this;
435
442
  }
436
- _create_class(_GraphQLClientError, [
443
+ _createClass(GraphQLClientError1, [
437
444
  {
438
445
  key: "message",
439
446
  get: function get() {
@@ -449,8 +456,8 @@ var GraphQLClientError = /*#__PURE__*/ function(Error1) {
449
456
  }
450
457
  }
451
458
  ]);
452
- return _GraphQLClientError;
453
- }(_wrap_native_super(Error));
459
+ return GraphQLClientError1;
460
+ }(_wrapNativeSuper(Error));
454
461
  // src/graphqlRequest.ts
455
462
  var sleep = function() {
456
463
  var ms = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
@@ -464,9 +471,9 @@ function graphqlRequest(_) {
464
471
  return _graphqlRequest.apply(this, arguments);
465
472
  }
466
473
  function _graphqlRequest() {
467
- _graphqlRequest = _async_to_generator(function(param) {
468
- var _param_shouldRetry, shouldRetry, _param_axios, axios, queryName, client, query, _param_requestHeaders, requestHeaders, variables, failureMode, errorsParser, _lastResponse_errors, lastResponse, maxRetrials, trial, _errors, _errors1, _client_retryConfig, infoParams, _ref, tmp, responseData, headers, status, data, errors, warnings, _client_retryConfig1;
469
- return _ts_generator(this, function(_state) {
474
+ _graphqlRequest = _asyncToGenerator(function(param) {
475
+ var _param_shouldRetry, shouldRetry, _param_axios, axios, queryName, client, query, _param_requestHeaders, requestHeaders, variables, failureMode, errorsParser, _lastResponse_errors, lastResponse, maxRetrials, trial, _client_retryConfig, infoParams, _ref, tmp, responseData, headers, status, data, errors, warnings, _client_retryConfig1;
476
+ return __generator(this, function(_state) {
470
477
  switch(_state.label){
471
478
  case 0:
472
479
  _param_shouldRetry = param.shouldRetry, shouldRetry = _param_shouldRetry === void 0 ? true : _param_shouldRetry, _param_axios = param.axios, axios = _param_axios === void 0 ? import_axios.default : _param_axios, queryName = param.queryName, client = param.client, query = param.query, _param_requestHeaders = param.requestHeaders, requestHeaders = _param_requestHeaders === void 0 ? {} : _param_requestHeaders, variables = param.variables, failureMode = param.failureMode, errorsParser = param.errorsParser;
@@ -478,7 +485,7 @@ function _graphqlRequest() {
478
485
  3,
479
486
  9
480
487
  ];
481
- infoParams = _object_spread({
488
+ infoParams = _objectSpread({
482
489
  _q: queryName
483
490
  }, trial > 0 ? {
484
491
  _retrial: trial + 1
@@ -491,7 +498,7 @@ function _graphqlRequest() {
491
498
  operationName: queryName
492
499
  }, {
493
500
  params: infoParams,
494
- headers: _object_spread({
501
+ headers: _objectSpread({
495
502
  "Content-Type": "application/json"
496
503
  }, client.headers, requestHeaders),
497
504
  validateStatus: function() {
@@ -502,7 +509,7 @@ function _graphqlRequest() {
502
509
  case 2:
503
510
  _ref = _state.sent(), tmp = _ref.data, responseData = tmp === void 0 ? {} : tmp, headers = _ref.headers, status = _ref.status;
504
511
  data = responseData.data, errors = responseData.errors, warnings = responseData.warnings;
505
- if (status >= 400 && !((_errors = errors) === null || _errors === void 0 ? void 0 : _errors.length)) {
512
+ if (status >= 400 && !(errors === null || errors === void 0 ? void 0 : errors.length)) {
506
513
  errors = [
507
514
  {
508
515
  message: 'Request "'.concat(queryName, '" failed with status ').concat(status)
@@ -516,7 +523,7 @@ function _graphqlRequest() {
516
523
  headers: headers,
517
524
  status: status
518
525
  };
519
- if (!!((_errors1 = errors) === null || _errors1 === void 0 ? void 0 : _errors1.length)) return [
526
+ if (!!(errors === null || errors === void 0 ? void 0 : errors.length)) return [
520
527
  3,
521
528
  3
522
529
  ];
@@ -599,17 +606,17 @@ function jsonToGraphQLQuery(param) {
599
606
  "__headers"
600
607
  ]));
601
608
  extractVariables({
602
- jsonQuery: _define_property({}, queryName, newJsonQuery),
609
+ jsonQuery: _defineProperty({}, queryName, newJsonQuery),
603
610
  variables: variablesData,
604
611
  parentType: kind === "query" ? typesTree.Query : typesTree.Mutation
605
612
  });
606
613
  var variablesQuery = Object.keys(variablesData).length ? "(".concat(entries(variablesData).map(function(param) {
607
- var _param = _sliced_to_array(param, 2), queryName2 = _param[0], type = _param[1].type;
614
+ var _param = _slicedToArray(param, 2), queryName2 = _param[0], type = _param[1].type;
608
615
  return "$".concat(queryName2, ": ").concat(type);
609
616
  }).join(", "), ")") : "";
610
617
  var query = "".concat(kind, " ").concat(alias || queryName).concat(variablesQuery, " { ").concat(alias ? "".concat(alias, ":") : "").concat(queryName).concat(toGraphql(newJsonQuery), " }");
611
618
  var variables = fromEntries(entries(variablesData).map(function(param) {
612
- var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
619
+ var _param = _slicedToArray(param, 2), k = _param[0], v = _param[1];
613
620
  return [
614
621
  k,
615
622
  v.value
@@ -648,18 +655,18 @@ function extractVariables(param) {
648
655
  }
649
656
  function toGraphql(jsonQuery) {
650
657
  var fields = entries(jsonQuery).filter(function(param) {
651
- var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
658
+ var _param = _slicedToArray(param, 2), k = _param[0], v = _param[1];
652
659
  return k !== "__args" && v !== false && v !== void 0;
653
660
  }).map(function(param) {
654
- var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
661
+ var _param = _slicedToArray(param, 2), k = _param[0], v = _param[1];
655
662
  return typeof v === "object" ? "".concat(k).concat(toGraphql(v)) : k;
656
663
  }).join(" ");
657
664
  var validArgs = jsonQuery.__args ? entries(jsonQuery.__args).filter(function(param) {
658
- var _param = _sliced_to_array(param, 2), _ = _param[0], v = _param[1];
665
+ var _param = _slicedToArray(param, 2), _ = _param[0], v = _param[1];
659
666
  return v !== void 0;
660
667
  }) : [];
661
668
  var argsQuery = validArgs.length ? "(".concat(validArgs.map(function(param) {
662
- var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
669
+ var _param = _slicedToArray(param, 2), k = _param[0], v = _param[1];
663
670
  return "".concat(k, ":").concat(v.substr(VAR_PREFIX_LENGTH));
664
671
  }).join(","), ")") : "";
665
672
  return "".concat(argsQuery, " ").concat(fields ? "{ ".concat(fields, " }") : "");
@@ -697,21 +704,21 @@ var executeListeners = function(listeners, data) {
697
704
  var getApiEndpointCreator = function(apiConfig) {
698
705
  return function(kind, queryName) {
699
706
  var rawEndpoint = function() {
700
- var _ref = _async_to_generator(function(failureMode, jsonQuery) {
701
- var _jsonQuery, _jsonQuery1, _jsonQuery2, _jsonQuery___alias, alias, _jsonQuery___retry, shouldRetry, _jsonQuery___headers, requestHeaders, _jsonToGraphQLQuery, query, variables, start, logOptions, responseListenerData, _data, _ref, data, errors, warnings, headers, status, response, error;
702
- return _ts_generator(this, function(_state) {
707
+ var _ref = _asyncToGenerator(function(failureMode, jsonQuery) {
708
+ var _jsonQuery___alias, alias, _jsonQuery___retry, shouldRetry, _jsonQuery___headers, requestHeaders, _jsonToGraphQLQuery, query, variables, start, logOptions, responseListenerData, _ref, data, errors, warnings, headers, status, response, error;
709
+ return __generator(this, function(_state) {
703
710
  switch(_state.label){
704
711
  case 0:
705
- alias = (_jsonQuery___alias = (_jsonQuery = jsonQuery) === null || _jsonQuery === void 0 ? void 0 : _jsonQuery.__alias) !== null && _jsonQuery___alias !== void 0 ? _jsonQuery___alias : queryName;
706
- shouldRetry = (_jsonQuery___retry = (_jsonQuery1 = jsonQuery) === null || _jsonQuery1 === void 0 ? void 0 : _jsonQuery1.__retry) !== null && _jsonQuery___retry !== void 0 ? _jsonQuery___retry : true;
707
- requestHeaders = (_jsonQuery___headers = (_jsonQuery2 = jsonQuery) === null || _jsonQuery2 === void 0 ? void 0 : _jsonQuery2.__headers) !== null && _jsonQuery___headers !== void 0 ? _jsonQuery___headers : {};
712
+ alias = (_jsonQuery___alias = jsonQuery === null || jsonQuery === void 0 ? void 0 : jsonQuery.__alias) !== null && _jsonQuery___alias !== void 0 ? _jsonQuery___alias : queryName;
713
+ shouldRetry = (_jsonQuery___retry = jsonQuery === null || jsonQuery === void 0 ? void 0 : jsonQuery.__retry) !== null && _jsonQuery___retry !== void 0 ? _jsonQuery___retry : true;
714
+ requestHeaders = (_jsonQuery___headers = jsonQuery === null || jsonQuery === void 0 ? void 0 : jsonQuery.__headers) !== null && _jsonQuery___headers !== void 0 ? _jsonQuery___headers : {};
708
715
  _jsonToGraphQLQuery = jsonToGraphQLQuery({
709
716
  kind: kind,
710
717
  queryName: queryName,
711
718
  jsonQuery: jsonQuery,
712
719
  typesTree: apiConfig.typesTree
713
720
  }), query = _jsonToGraphQLQuery.query, variables = _jsonToGraphQLQuery.variables;
714
- start = +/* @__PURE__ */ new Date();
721
+ start = +new Date();
715
722
  logOptions = {
716
723
  kind: kind,
717
724
  queryName: alias,
@@ -756,18 +763,18 @@ var getApiEndpointCreator = function(apiConfig) {
756
763
  errors: errors
757
764
  };
758
765
  if (apiConfig.verbose && globalThis.document) {
759
- logRequest(_object_spread_props(_object_spread({}, logOptions), {
766
+ logRequest(_objectSpreadProps(_objectSpread({}, logOptions), {
760
767
  response: response,
761
- duration: +/* @__PURE__ */ new Date() - start
768
+ duration: +new Date() - start
762
769
  }));
763
770
  }
764
- executeListeners(apiConfig.responseListeners, _object_spread_props(_object_spread({}, responseListenerData), {
771
+ executeListeners(apiConfig.responseListeners, _objectSpreadProps(_objectSpread({}, responseListenerData), {
765
772
  response: response
766
773
  }));
767
774
  return [
768
775
  2,
769
776
  {
770
- data: (_data = data) === null || _data === void 0 ? void 0 : _data[alias],
777
+ data: data === null || data === void 0 ? void 0 : data[alias],
771
778
  errors: errors,
772
779
  warnings: warnings,
773
780
  headers: headers,
@@ -777,12 +784,12 @@ var getApiEndpointCreator = function(apiConfig) {
777
784
  case 3:
778
785
  error = _state.sent();
779
786
  if (apiConfig.verbose && globalThis.document) {
780
- logRequest(_object_spread_props(_object_spread({}, logOptions), {
787
+ logRequest(_objectSpreadProps(_objectSpread({}, logOptions), {
781
788
  error: error,
782
- duration: +/* @__PURE__ */ new Date() - start
789
+ duration: +new Date() - start
783
790
  }));
784
791
  }
785
- executeListeners(apiConfig.responseListeners, _object_spread_props(_object_spread({}, responseListenerData), {
792
+ executeListeners(apiConfig.responseListeners, _objectSpreadProps(_objectSpread({}, responseListenerData), {
786
793
  response: error.response
787
794
  }));
788
795
  throw error;
@@ -798,9 +805,9 @@ var getApiEndpointCreator = function(apiConfig) {
798
805
  };
799
806
  }();
800
807
  var endpoint = function() {
801
- var _ref = _async_to_generator(function(jsonQuery) {
808
+ var _ref = _asyncToGenerator(function(jsonQuery) {
802
809
  var data;
803
- return _ts_generator(this, function(_state) {
810
+ return __generator(this, function(_state) {
804
811
  switch(_state.label){
805
812
  case 0:
806
813
  return [
package/dist/index.d.ts CHANGED
@@ -14,9 +14,11 @@ type IClientOptions = {
14
14
  skipCache?: boolean;
15
15
  errorsParser?: (errors: any[]) => any;
16
16
  };
17
- declare function generateTypescriptClient({ introspectionEndpoint, output, ...options }: IClientOptions): Promise<{
17
+ type Client = {
18
18
  typings: string;
19
19
  js: string;
20
- }>;
20
+ };
21
+ declare function generateTypescriptClient({ introspectionEndpoint, ...options }: IClientOptions): Promise<Client>;
22
+ declare function generateTypescriptClientFromSDL(SDL: string, options: IClientOptions): Client;
21
23
 
22
- export { generateTypescriptClient };
24
+ export { generateTypescriptClient, generateTypescriptClientFromSDL };