@luvio/graphql-parser 0.62.3 → 0.63.2
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/dist/luvioGraphqlParser.js +120 -148
- package/package.json +1 -1
- package/rollup.config.js +1 -1
|
@@ -4,8 +4,9 @@ var SYMBOL_TO_STRING_TAG = typeof Symbol === 'function' && Symbol.toStringTag !=
|
|
|
4
4
|
|
|
5
5
|
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
6
6
|
var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
|
|
7
|
+
var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
|
|
7
8
|
|
|
8
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
9
|
+
function _typeof$3(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$3 = function _typeof(obj) { return typeof obj; }; } else { _typeof$3 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$3(obj); }
|
|
9
10
|
var MAX_ARRAY_LENGTH = 10;
|
|
10
11
|
var MAX_RECURSIVE_DEPTH = 2;
|
|
11
12
|
/**
|
|
@@ -17,7 +18,7 @@ function inspect(value) {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
function formatValue(value, seenValues) {
|
|
20
|
-
switch (_typeof(value)) {
|
|
21
|
+
switch (_typeof$3(value)) {
|
|
21
22
|
case 'string':
|
|
22
23
|
return JSON.stringify(value);
|
|
23
24
|
|
|
@@ -102,7 +103,7 @@ function formatArray(array, seenValues) {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
function getCustomFn(object) {
|
|
105
|
-
var customInspectFn = object[String(nodejsCustomInspectSymbol)];
|
|
106
|
+
var customInspectFn = object[String(nodejsCustomInspectSymbol$1)];
|
|
106
107
|
|
|
107
108
|
if (typeof customInspectFn === 'function') {
|
|
108
109
|
return customInspectFn;
|
|
@@ -135,10 +136,12 @@ function devAssert(condition, message) {
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
|
|
139
|
+
function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
|
|
138
140
|
/**
|
|
139
141
|
* A replacement for instanceof which includes an error warning when multi-realm
|
|
140
142
|
* constructors are detected.
|
|
141
143
|
*/
|
|
144
|
+
|
|
142
145
|
// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
|
|
143
146
|
// See: https://webpack.js.org/guides/production/
|
|
144
147
|
var instanceOf = process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
@@ -151,21 +154,25 @@ function instanceOf(value, constructor) {
|
|
|
151
154
|
return true;
|
|
152
155
|
}
|
|
153
156
|
|
|
154
|
-
if (value) {
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
+
if (_typeof$2(value) === 'object' && value !== null) {
|
|
158
|
+
var _value$constructor;
|
|
159
|
+
|
|
160
|
+
var className = constructor.prototype[Symbol.toStringTag];
|
|
161
|
+
var valueClassName = // We still need to support constructor's name to detect conflicts with older versions of this library.
|
|
162
|
+
Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name;
|
|
157
163
|
|
|
158
|
-
if (className
|
|
159
|
-
|
|
164
|
+
if (className === valueClassName) {
|
|
165
|
+
var stringifiedValue = inspect(value);
|
|
166
|
+
throw new Error("Cannot use ".concat(className, " \"").concat(stringifiedValue, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."));
|
|
160
167
|
}
|
|
161
168
|
}
|
|
162
169
|
|
|
163
170
|
return false;
|
|
164
171
|
};
|
|
165
172
|
|
|
166
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
173
|
+
function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
167
174
|
|
|
168
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
175
|
+
function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
|
|
169
176
|
|
|
170
177
|
/**
|
|
171
178
|
* A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
|
|
@@ -190,7 +197,7 @@ var Source = /*#__PURE__*/function () {
|
|
|
190
197
|
} // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
|
|
191
198
|
|
|
192
199
|
|
|
193
|
-
_createClass(Source, [{
|
|
200
|
+
_createClass$1(Source, [{
|
|
194
201
|
key: SYMBOL_TO_STRING_TAG,
|
|
195
202
|
get: function get() {
|
|
196
203
|
return 'Source';
|
|
@@ -278,8 +285,8 @@ function printSourceLocation(source, sourceLocation) {
|
|
|
278
285
|
|
|
279
286
|
function printPrefixedLines(lines) {
|
|
280
287
|
var existingLines = lines.filter(function (_ref) {
|
|
281
|
-
|
|
282
|
-
line = _ref[1];
|
|
288
|
+
_ref[0];
|
|
289
|
+
var line = _ref[1];
|
|
283
290
|
return line !== undefined;
|
|
284
291
|
});
|
|
285
292
|
var padLen = Math.max.apply(Math, existingLines.map(function (_ref2) {
|
|
@@ -406,19 +413,25 @@ function isObjectLike(value) {
|
|
|
406
413
|
return _typeof$1(value) == 'object' && value !== null;
|
|
407
414
|
}
|
|
408
415
|
|
|
409
|
-
function _typeof
|
|
416
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
417
|
+
|
|
418
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
419
|
+
|
|
420
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
421
|
+
|
|
422
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
410
423
|
|
|
411
424
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
412
425
|
|
|
413
|
-
function _defineProperties
|
|
426
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
414
427
|
|
|
415
|
-
function _createClass
|
|
428
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
416
429
|
|
|
417
430
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
418
431
|
|
|
419
432
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
420
433
|
|
|
421
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof
|
|
434
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
422
435
|
|
|
423
436
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
424
437
|
|
|
@@ -445,14 +458,6 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
445
458
|
|
|
446
459
|
var _super = _createSuper(GraphQLError);
|
|
447
460
|
|
|
448
|
-
/**
|
|
449
|
-
* A message describing the Error for debugging purposes.
|
|
450
|
-
*
|
|
451
|
-
* Enumerable, and appears in the result of JSON.stringify().
|
|
452
|
-
*
|
|
453
|
-
* Note: should be treated as readonly, despite invariant usage.
|
|
454
|
-
*/
|
|
455
|
-
|
|
456
461
|
/**
|
|
457
462
|
* An array of { line, column } locations within the source GraphQL document
|
|
458
463
|
* which correspond to this error.
|
|
@@ -495,117 +500,79 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
495
500
|
* Extension fields to add to the formatted error.
|
|
496
501
|
*/
|
|
497
502
|
function GraphQLError(message, nodes, source, positions, path, originalError, extensions) {
|
|
498
|
-
var
|
|
503
|
+
var _nodeLocations, _nodeLocations2, _nodeLocations3;
|
|
499
504
|
|
|
500
505
|
var _this;
|
|
501
506
|
|
|
502
507
|
_classCallCheck(this, GraphQLError);
|
|
503
508
|
|
|
504
|
-
_this = _super.call(this, message);
|
|
509
|
+
_this = _super.call(this, message);
|
|
510
|
+
_this.name = 'GraphQLError';
|
|
511
|
+
_this.originalError = originalError !== null && originalError !== void 0 ? originalError : undefined; // Compute list of blame nodes.
|
|
505
512
|
|
|
506
|
-
|
|
513
|
+
_this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined);
|
|
514
|
+
var nodeLocations = [];
|
|
507
515
|
|
|
516
|
+
for (var _i2 = 0, _ref3 = (_this$nodes = _this.nodes) !== null && _this$nodes !== void 0 ? _this$nodes : []; _i2 < _ref3.length; _i2++) {
|
|
517
|
+
var _this$nodes;
|
|
508
518
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
if (!_source && _nodes) {
|
|
512
|
-
var _nodes$0$loc;
|
|
513
|
-
|
|
514
|
-
_source = (_nodes$0$loc = _nodes[0].loc) === null || _nodes$0$loc === void 0 ? void 0 : _nodes$0$loc.source;
|
|
515
|
-
}
|
|
519
|
+
var _ref4 = _ref3[_i2];
|
|
520
|
+
var loc = _ref4.loc;
|
|
516
521
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
_positions = _nodes.reduce(function (list, node) {
|
|
521
|
-
if (node.loc) {
|
|
522
|
-
list.push(node.loc.start);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
return list;
|
|
526
|
-
}, []);
|
|
522
|
+
if (loc != null) {
|
|
523
|
+
nodeLocations.push(loc);
|
|
524
|
+
}
|
|
527
525
|
}
|
|
528
526
|
|
|
529
|
-
|
|
530
|
-
_positions = undefined;
|
|
531
|
-
}
|
|
527
|
+
nodeLocations = undefinedIfEmpty(nodeLocations); // Compute locations in the source for the given nodes/positions.
|
|
532
528
|
|
|
533
|
-
|
|
529
|
+
_this.source = source !== null && source !== void 0 ? source : (_nodeLocations = nodeLocations) === null || _nodeLocations === void 0 ? void 0 : _nodeLocations[0].source;
|
|
530
|
+
_this.positions = positions !== null && positions !== void 0 ? positions : (_nodeLocations2 = nodeLocations) === null || _nodeLocations2 === void 0 ? void 0 : _nodeLocations2.map(function (loc) {
|
|
531
|
+
return loc.start;
|
|
532
|
+
});
|
|
533
|
+
_this.locations = positions && source ? positions.map(function (pos) {
|
|
534
|
+
return getLocation(source, pos);
|
|
535
|
+
}) : (_nodeLocations3 = nodeLocations) === null || _nodeLocations3 === void 0 ? void 0 : _nodeLocations3.map(function (loc) {
|
|
536
|
+
return getLocation(loc.source, loc.start);
|
|
537
|
+
});
|
|
538
|
+
_this.path = path !== null && path !== void 0 ? path : undefined;
|
|
539
|
+
var originalExtensions = originalError === null || originalError === void 0 ? void 0 : originalError.extensions;
|
|
534
540
|
|
|
535
|
-
if (
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
if (node.loc) {
|
|
542
|
-
list.push(getLocation(node.loc.source, node.loc.start));
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
return list;
|
|
546
|
-
}, []);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
var _extensions = extensions;
|
|
541
|
+
if (extensions == null && isObjectLike(originalExtensions)) {
|
|
542
|
+
_this.extensions = _objectSpread({}, originalExtensions);
|
|
543
|
+
} else {
|
|
544
|
+
_this.extensions = extensions !== null && extensions !== void 0 ? extensions : {};
|
|
545
|
+
} // By being enumerable, JSON.stringify will include bellow properties in the resulting output.
|
|
546
|
+
// This ensures that the simplest possible GraphQL service adheres to the spec.
|
|
550
547
|
|
|
551
|
-
if (_extensions == null && originalError != null) {
|
|
552
|
-
var originalExtensions = originalError.extensions;
|
|
553
|
-
|
|
554
|
-
if (isObjectLike(originalExtensions)) {
|
|
555
|
-
_extensions = originalExtensions;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
548
|
|
|
559
549
|
Object.defineProperties(_assertThisInitialized(_this), {
|
|
560
|
-
name: {
|
|
561
|
-
value: 'GraphQLError'
|
|
562
|
-
},
|
|
563
550
|
message: {
|
|
564
|
-
|
|
565
|
-
// By being enumerable, JSON.stringify will include `message` in the
|
|
566
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
567
|
-
// service adheres to the spec.
|
|
568
|
-
enumerable: true,
|
|
569
|
-
writable: true
|
|
551
|
+
enumerable: true
|
|
570
552
|
},
|
|
571
553
|
locations: {
|
|
572
|
-
|
|
573
|
-
// in JSON.stringify() when not provided.
|
|
574
|
-
value: (_locations2 = _locations) !== null && _locations2 !== void 0 ? _locations2 : undefined,
|
|
575
|
-
// By being enumerable, JSON.stringify will include `locations` in the
|
|
576
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
577
|
-
// service adheres to the spec.
|
|
578
|
-
enumerable: _locations != null
|
|
554
|
+
enumerable: _this.locations != null
|
|
579
555
|
},
|
|
580
556
|
path: {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
enumerable:
|
|
557
|
+
enumerable: _this.path != null
|
|
558
|
+
},
|
|
559
|
+
extensions: {
|
|
560
|
+
enumerable: _this.extensions != null && Object.keys(_this.extensions).length > 0
|
|
561
|
+
},
|
|
562
|
+
name: {
|
|
563
|
+
enumerable: false
|
|
588
564
|
},
|
|
589
565
|
nodes: {
|
|
590
|
-
|
|
566
|
+
enumerable: false
|
|
591
567
|
},
|
|
592
568
|
source: {
|
|
593
|
-
|
|
569
|
+
enumerable: false
|
|
594
570
|
},
|
|
595
571
|
positions: {
|
|
596
|
-
|
|
572
|
+
enumerable: false
|
|
597
573
|
},
|
|
598
574
|
originalError: {
|
|
599
|
-
|
|
600
|
-
},
|
|
601
|
-
extensions: {
|
|
602
|
-
// Coercing falsy values to undefined ensures they will not be included
|
|
603
|
-
// in JSON.stringify() when not provided.
|
|
604
|
-
value: (_extensions2 = _extensions) !== null && _extensions2 !== void 0 ? _extensions2 : undefined,
|
|
605
|
-
// By being enumerable, JSON.stringify will include `path` in the
|
|
606
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
607
|
-
// service adheres to the spec.
|
|
608
|
-
enumerable: _extensions != null
|
|
575
|
+
enumerable: false
|
|
609
576
|
}
|
|
610
577
|
}); // Include (non-enumerable) stack trace.
|
|
611
578
|
|
|
@@ -632,7 +599,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
632
599
|
return _this;
|
|
633
600
|
}
|
|
634
601
|
|
|
635
|
-
_createClass
|
|
602
|
+
_createClass(GraphQLError, [{
|
|
636
603
|
key: "toString",
|
|
637
604
|
value: function toString() {
|
|
638
605
|
return printError(this);
|
|
@@ -648,25 +615,30 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
648
615
|
|
|
649
616
|
return GraphQLError;
|
|
650
617
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
618
|
+
|
|
619
|
+
function undefinedIfEmpty(array) {
|
|
620
|
+
return array === undefined || array.length === 0 ? undefined : array;
|
|
621
|
+
}
|
|
651
622
|
/**
|
|
652
623
|
* Prints a GraphQLError to a string, representing useful location information
|
|
653
624
|
* about the error's position in the source.
|
|
654
625
|
*/
|
|
655
626
|
|
|
627
|
+
|
|
656
628
|
function printError(error) {
|
|
657
629
|
var output = error.message;
|
|
658
630
|
|
|
659
631
|
if (error.nodes) {
|
|
660
|
-
for (var
|
|
661
|
-
var node = _error$nodes2[
|
|
632
|
+
for (var _i4 = 0, _error$nodes2 = error.nodes; _i4 < _error$nodes2.length; _i4++) {
|
|
633
|
+
var node = _error$nodes2[_i4];
|
|
662
634
|
|
|
663
635
|
if (node.loc) {
|
|
664
636
|
output += '\n\n' + printLocation(node.loc);
|
|
665
637
|
}
|
|
666
638
|
}
|
|
667
639
|
} else if (error.source && error.locations) {
|
|
668
|
-
for (var
|
|
669
|
-
var location = _error$locations2[
|
|
640
|
+
for (var _i6 = 0, _error$locations2 = error.locations; _i6 < _error$locations2.length; _i6++) {
|
|
641
|
+
var location = _error$locations2[_i6];
|
|
670
642
|
output += '\n\n' + printSourceLocation(error.source, location);
|
|
671
643
|
}
|
|
672
644
|
}
|
|
@@ -700,8 +672,8 @@ function defineInspect(classObject) {
|
|
|
700
672
|
typeof fn === 'function' || invariant(0);
|
|
701
673
|
classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
702
674
|
|
|
703
|
-
if (nodejsCustomInspectSymbol) {
|
|
704
|
-
classObject.prototype[nodejsCustomInspectSymbol] = fn;
|
|
675
|
+
if (nodejsCustomInspectSymbol$1) {
|
|
676
|
+
classObject.prototype[nodejsCustomInspectSymbol$1] = fn;
|
|
705
677
|
}
|
|
706
678
|
}
|
|
707
679
|
|
|
@@ -3483,7 +3455,7 @@ const NODE_KIND_OBJECT_FIELD_SELECTION = 'ObjectFieldSelection';
|
|
|
3483
3455
|
const NODE_KIND_SCALAR_FIELD_SELECTION = 'ScalarFieldSelection';
|
|
3484
3456
|
const NODE_TYPE_CONNECTION = 'Connection';
|
|
3485
3457
|
|
|
3486
|
-
function transform(node, transformState) {
|
|
3458
|
+
function transform$b(node, transformState) {
|
|
3487
3459
|
switch (node.kind) {
|
|
3488
3460
|
case 'Variable':
|
|
3489
3461
|
transformState.variablesUsed[node.name.value] = true;
|
|
@@ -3523,7 +3495,7 @@ function transform(node, transformState) {
|
|
|
3523
3495
|
case 'ListValue': {
|
|
3524
3496
|
const values = [];
|
|
3525
3497
|
for (var index = 0; index < node.values.length; index++) {
|
|
3526
|
-
const value = transform(node.values[index], transformState);
|
|
3498
|
+
const value = transform$b(node.values[index], transformState);
|
|
3527
3499
|
values.push(value);
|
|
3528
3500
|
}
|
|
3529
3501
|
return {
|
|
@@ -3536,7 +3508,7 @@ function transform(node, transformState) {
|
|
|
3536
3508
|
const result = {};
|
|
3537
3509
|
fields.forEach((field) => {
|
|
3538
3510
|
const name = field.name.value;
|
|
3539
|
-
const value = transform(field.value, transformState);
|
|
3511
|
+
const value = transform$b(field.value, transformState);
|
|
3540
3512
|
result[name] = value;
|
|
3541
3513
|
});
|
|
3542
3514
|
return {
|
|
@@ -3549,9 +3521,9 @@ function transform(node, transformState) {
|
|
|
3549
3521
|
}
|
|
3550
3522
|
}
|
|
3551
3523
|
|
|
3552
|
-
function transform$
|
|
3524
|
+
function transform$a(node, transformState) {
|
|
3553
3525
|
const { kind, name: { value: nodeName }, value: nodeValue, } = node;
|
|
3554
|
-
const valueNode = transform(nodeValue, transformState);
|
|
3526
|
+
const valueNode = transform$b(nodeValue, transformState);
|
|
3555
3527
|
return {
|
|
3556
3528
|
kind,
|
|
3557
3529
|
name: nodeName,
|
|
@@ -3559,7 +3531,7 @@ function transform$1(node, transformState) {
|
|
|
3559
3531
|
};
|
|
3560
3532
|
}
|
|
3561
3533
|
|
|
3562
|
-
function transform$
|
|
3534
|
+
function transform$9(node, transformState) {
|
|
3563
3535
|
const { kind, name: { value: nodeName }, arguments: nodeArguments, } = node;
|
|
3564
3536
|
const ret = {
|
|
3565
3537
|
kind,
|
|
@@ -3569,7 +3541,7 @@ function transform$2(node, transformState) {
|
|
|
3569
3541
|
let returnArguments = [];
|
|
3570
3542
|
for (var index = 0; index < nodeArguments.length; index++) {
|
|
3571
3543
|
const argumentNode = nodeArguments[index];
|
|
3572
|
-
const value = transform$
|
|
3544
|
+
const value = transform$a(argumentNode, transformState);
|
|
3573
3545
|
returnArguments.push(value);
|
|
3574
3546
|
}
|
|
3575
3547
|
ret.arguments = returnArguments;
|
|
@@ -3581,7 +3553,7 @@ function isCustomDirective(node) {
|
|
|
3581
3553
|
node.name.value === CUSTOM_DIRECTIVE_RESOURCE);
|
|
3582
3554
|
}
|
|
3583
3555
|
|
|
3584
|
-
function transform$
|
|
3556
|
+
function transform$8(node, transformState) {
|
|
3585
3557
|
const { name, alias, arguments: fieldArgs, selectionSet, directives } = node;
|
|
3586
3558
|
let luvioNode = {
|
|
3587
3559
|
kind: NODE_KIND_OBJECT_FIELD_SELECTION,
|
|
@@ -3600,7 +3572,7 @@ function transform$3(node, transformState) {
|
|
|
3600
3572
|
const customDirectiveNode = directives.find(isCustomDirective);
|
|
3601
3573
|
if (customDirectiveNode === undefined) {
|
|
3602
3574
|
// transform non client-side directives
|
|
3603
|
-
luvioNode.directives = directives.map((directive) => transform$
|
|
3575
|
+
luvioNode.directives = directives.map((directive) => transform$9(directive, transformState));
|
|
3604
3576
|
}
|
|
3605
3577
|
else {
|
|
3606
3578
|
if (customDirectiveNode.name.value === CUSTOM_DIRECTIVE_CONNECTION) {
|
|
@@ -3624,7 +3596,7 @@ function transform$3(node, transformState) {
|
|
|
3624
3596
|
if (fieldArgs !== undefined && fieldArgs.length > 0) {
|
|
3625
3597
|
const returnArguments = [];
|
|
3626
3598
|
for (var index = 0; index < fieldArgs.length; index++) {
|
|
3627
|
-
const value = transform$
|
|
3599
|
+
const value = transform$a(fieldArgs[index], transformState);
|
|
3628
3600
|
returnArguments.push(value);
|
|
3629
3601
|
}
|
|
3630
3602
|
luvioNode.arguments = returnArguments;
|
|
@@ -3636,19 +3608,19 @@ function transform$3(node, transformState) {
|
|
|
3636
3608
|
return luvioNode;
|
|
3637
3609
|
}
|
|
3638
3610
|
|
|
3639
|
-
function transform$
|
|
3611
|
+
function transform$7(node, transformState) {
|
|
3640
3612
|
const { kind, name: { value }, directives, } = node;
|
|
3641
3613
|
const luvioNode = {
|
|
3642
3614
|
kind,
|
|
3643
3615
|
name: value,
|
|
3644
3616
|
};
|
|
3645
3617
|
if (directives !== undefined && directives.length > 0) {
|
|
3646
|
-
luvioNode.directives = directives.map((directive) => transform$
|
|
3618
|
+
luvioNode.directives = directives.map((directive) => transform$9(directive, transformState));
|
|
3647
3619
|
}
|
|
3648
3620
|
return luvioNode;
|
|
3649
3621
|
}
|
|
3650
3622
|
|
|
3651
|
-
function transform$
|
|
3623
|
+
function transform$6(node, transformState) {
|
|
3652
3624
|
const { kind: nodeKind, typeCondition, directives } = node;
|
|
3653
3625
|
const luvioNode = {
|
|
3654
3626
|
kind: nodeKind,
|
|
@@ -3661,7 +3633,7 @@ function transform$5(node, transformState) {
|
|
|
3661
3633
|
};
|
|
3662
3634
|
}
|
|
3663
3635
|
if (directives !== undefined && directives.length > 0) {
|
|
3664
|
-
luvioNode.directives = directives.map((directive) => transform$
|
|
3636
|
+
luvioNode.directives = directives.map((directive) => transform$9(directive, transformState));
|
|
3665
3637
|
}
|
|
3666
3638
|
return luvioNode;
|
|
3667
3639
|
}
|
|
@@ -3672,15 +3644,15 @@ function selectionSetVisitor(ast, luvioSelectionPath, transformState) {
|
|
|
3672
3644
|
let selectionNode;
|
|
3673
3645
|
switch (node.kind) {
|
|
3674
3646
|
case NODE_KIND_FIELD: {
|
|
3675
|
-
const fieldNode = transform$
|
|
3647
|
+
const fieldNode = transform$8(node, transformState);
|
|
3676
3648
|
selectionNode = fieldNode;
|
|
3677
3649
|
break;
|
|
3678
3650
|
}
|
|
3679
3651
|
case NODE_KIND_FRAGMENT_SPREAD:
|
|
3680
|
-
selectionNode = transform$
|
|
3652
|
+
selectionNode = transform$7(node, transformState);
|
|
3681
3653
|
break;
|
|
3682
3654
|
case NODE_KIND_INLINE_FRAGMENT:
|
|
3683
|
-
selectionNode = transform$
|
|
3655
|
+
selectionNode = transform$6(node, transformState);
|
|
3684
3656
|
break;
|
|
3685
3657
|
}
|
|
3686
3658
|
if (selectionNode !== undefined) {
|
|
@@ -3706,7 +3678,7 @@ function selectionSetVisitor(ast, luvioSelectionPath, transformState) {
|
|
|
3706
3678
|
visit(ast, visitor);
|
|
3707
3679
|
}
|
|
3708
3680
|
|
|
3709
|
-
function transform$
|
|
3681
|
+
function transform$5(node) {
|
|
3710
3682
|
if (isNamedTypeNode(node)) {
|
|
3711
3683
|
return {
|
|
3712
3684
|
kind: NODE_KIND_NAMED_TYPE,
|
|
@@ -3716,7 +3688,7 @@ function transform$6(node) {
|
|
|
3716
3688
|
else if (isListTypeNode(node)) {
|
|
3717
3689
|
return {
|
|
3718
3690
|
kind: NODE_KIND_LIST_TYPE,
|
|
3719
|
-
type: transform$
|
|
3691
|
+
type: transform$5(node.type),
|
|
3720
3692
|
};
|
|
3721
3693
|
}
|
|
3722
3694
|
else if (isNonNullTypeNode(node)) {
|
|
@@ -3734,7 +3706,7 @@ function transform$6(node) {
|
|
|
3734
3706
|
kind: NODE_KIND_NON_NULL_TYPE,
|
|
3735
3707
|
type: {
|
|
3736
3708
|
kind: NODE_KIND_LIST_TYPE,
|
|
3737
|
-
type: transform$
|
|
3709
|
+
type: transform$5(node.type.type),
|
|
3738
3710
|
},
|
|
3739
3711
|
};
|
|
3740
3712
|
}
|
|
@@ -3747,7 +3719,7 @@ function transform$6(node) {
|
|
|
3747
3719
|
}
|
|
3748
3720
|
}
|
|
3749
3721
|
|
|
3750
|
-
function transform$
|
|
3722
|
+
function transform$4(variableDefinitions, transformState) {
|
|
3751
3723
|
const { kind, variable: { kind: variableKind, name: { value: variableName }, }, type, defaultValue, } = variableDefinitions;
|
|
3752
3724
|
const ret = {
|
|
3753
3725
|
kind,
|
|
@@ -3755,17 +3727,17 @@ function transform$7(variableDefinitions, transformState) {
|
|
|
3755
3727
|
kind: variableKind,
|
|
3756
3728
|
name: variableName,
|
|
3757
3729
|
},
|
|
3758
|
-
type: transform$
|
|
3730
|
+
type: transform$5(type),
|
|
3759
3731
|
};
|
|
3760
3732
|
if (defaultValue !== undefined) {
|
|
3761
|
-
const value = transform(defaultValue, transformState);
|
|
3733
|
+
const value = transform$b(defaultValue, transformState);
|
|
3762
3734
|
ret.defaultValue = value;
|
|
3763
3735
|
}
|
|
3764
3736
|
// TODO: transform directives
|
|
3765
3737
|
return ret;
|
|
3766
3738
|
}
|
|
3767
3739
|
|
|
3768
|
-
function transform$
|
|
3740
|
+
function transform$3(node) {
|
|
3769
3741
|
const queryRoot = {
|
|
3770
3742
|
kind: 'ObjectFieldSelection',
|
|
3771
3743
|
name: 'query',
|
|
@@ -3786,10 +3758,10 @@ function transform$8(node) {
|
|
|
3786
3758
|
}
|
|
3787
3759
|
const { variableDefinitions, directives } = node;
|
|
3788
3760
|
if (variableDefinitions !== undefined && variableDefinitions.length > 0) {
|
|
3789
|
-
operationDefinition.variableDefinitions = variableDefinitions.map((variableDefinition) => transform$
|
|
3761
|
+
operationDefinition.variableDefinitions = variableDefinitions.map((variableDefinition) => transform$4(variableDefinition, transformState));
|
|
3790
3762
|
}
|
|
3791
3763
|
if (directives !== undefined && directives.length > 0) {
|
|
3792
|
-
operationDefinition.directives = directives.map((node) => transform$
|
|
3764
|
+
operationDefinition.directives = directives.map((node) => transform$9(node, transformState));
|
|
3793
3765
|
}
|
|
3794
3766
|
validateVariables(variableDefinitions, transformState);
|
|
3795
3767
|
return operationDefinition;
|
|
@@ -3817,15 +3789,15 @@ function validateVariables(variableDefinitions, transformState) {
|
|
|
3817
3789
|
}
|
|
3818
3790
|
}
|
|
3819
3791
|
|
|
3820
|
-
function transform$
|
|
3792
|
+
function transform$2(node) {
|
|
3821
3793
|
const { operation } = node;
|
|
3822
3794
|
if (operation === 'query') {
|
|
3823
|
-
return transform$
|
|
3795
|
+
return transform$3(node);
|
|
3824
3796
|
}
|
|
3825
3797
|
throw new Error(`Unsupported ${operation} operation. Only query operation is supported`);
|
|
3826
3798
|
}
|
|
3827
3799
|
|
|
3828
|
-
function transform$
|
|
3800
|
+
function transform$1(node) {
|
|
3829
3801
|
const { kind: nodeKind, name: { value: nodeName }, typeCondition: { kind: typeKind, name: { value: typeName }, }, directives, } = node;
|
|
3830
3802
|
// dummy root node
|
|
3831
3803
|
const fragmentRoot = {
|
|
@@ -3846,21 +3818,21 @@ function transform$a(node) {
|
|
|
3846
3818
|
luvioSelections: fragmentRoot.luvioSelections,
|
|
3847
3819
|
};
|
|
3848
3820
|
if (directives !== undefined && directives.length > 0) {
|
|
3849
|
-
luvioNode.directives = directives.map((node) => transform$
|
|
3821
|
+
luvioNode.directives = directives.map((node) => transform$9(node, transformState));
|
|
3850
3822
|
}
|
|
3851
3823
|
return luvioNode;
|
|
3852
3824
|
}
|
|
3853
3825
|
|
|
3854
|
-
function transform
|
|
3826
|
+
function transform(root) {
|
|
3855
3827
|
const { kind, definitions } = root;
|
|
3856
3828
|
const luvioDefinitions = [];
|
|
3857
3829
|
for (let i = 0; i < definitions.length; i++) {
|
|
3858
3830
|
const definition = definitions[i];
|
|
3859
3831
|
if (isOperationDefinitionNode(definition)) {
|
|
3860
|
-
luvioDefinitions.push(transform$
|
|
3832
|
+
luvioDefinitions.push(transform$2(definition));
|
|
3861
3833
|
}
|
|
3862
3834
|
else if (isFragmentDefinitionNode(definition)) {
|
|
3863
|
-
luvioDefinitions.push(transform$
|
|
3835
|
+
luvioDefinitions.push(transform$1(definition));
|
|
3864
3836
|
}
|
|
3865
3837
|
else {
|
|
3866
3838
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -3877,7 +3849,7 @@ function transform$b(root) {
|
|
|
3877
3849
|
function parseAndVisit(source) {
|
|
3878
3850
|
// TODO: handle generic <Type>
|
|
3879
3851
|
const ast = parse(source);
|
|
3880
|
-
return transform
|
|
3852
|
+
return transform(ast);
|
|
3881
3853
|
}
|
|
3882
3854
|
|
|
3883
3855
|
export { parseAndVisit };
|
package/package.json
CHANGED
package/rollup.config.js
CHANGED