msw 0.21.3 → 0.22.3
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 +3 -9
- package/lib/esm/errors-deps.js +6 -7
- package/lib/esm/fetch-deps.js +44 -22
- package/lib/esm/{matchRequestUrl-deps.js → getCallFrame-deps.js} +32 -5
- package/lib/esm/graphql.js +601 -465
- package/lib/esm/index.js +56 -50
- package/lib/esm/mockServiceWorker.js +16 -10
- package/lib/esm/rest-deps.js +10 -1
- package/lib/esm/rest.js +1 -1
- package/lib/types/context/errors.d.ts +3 -3
- package/lib/types/context/json.d.ts +5 -1
- package/lib/types/index.d.ts +3 -2
- package/lib/types/native/index.d.ts +1 -7
- package/lib/types/node/createSetupServer.d.ts +2 -23
- package/{node/node/createSetupServer.d.ts → lib/types/node/glossary.d.ts} +12 -13
- package/lib/types/node/index.d.ts +1 -0
- package/lib/types/node/setupServer.d.ts +1 -7
- package/lib/types/response.d.ts +7 -2
- package/lib/types/rest.d.ts +60 -30
- package/lib/types/setupWorker/glossary.d.ts +22 -0
- package/lib/types/setupWorker/setupWorker.d.ts +1 -19
- package/lib/types/utils/handlers/requestHandler.d.ts +13 -1
- package/lib/types/utils/internal/getCallFrame.d.ts +4 -0
- package/lib/types/utils/internal/isObject.d.ts +4 -0
- package/lib/types/utils/internal/mergeRight.d.ts +1 -1
- package/lib/types/utils/request/onUnhandledRequest.d.ts +1 -1
- package/lib/umd/index.js +720 -519
- package/lib/umd/mockServiceWorker.js +16 -10
- package/native/index.js +2017 -125
- package/node/index.js +2017 -125
- package/package.json +34 -32
- package/lib/types/LiveStorage.d.ts +0 -17
- package/node/context/delay.d.ts +0 -11
- package/node/context/fetch.d.ts +0 -8
- package/node/context/set.d.ts +0 -2
- package/node/context/status.d.ts +0 -2
- package/node/node/index.d.ts +0 -5
- package/node/node/setupServer.d.ts +0 -7
- package/node/response.d.ts +0 -25
- package/node/utils/NetworkError.d.ts +0 -3
- package/node/utils/getResponse.d.ts +0 -14
- package/node/utils/handlers/requestHandler.d.ts +0 -74
- package/node/utils/handlers/requestHandlerUtils.d.ts +0 -4
- package/node/utils/internal/compose.d.ts +0 -5
- package/node/utils/internal/isNodeProcess.d.ts +0 -5
- package/node/utils/internal/jsonParse.d.ts +0 -5
- package/node/utils/request/getPublicUrlFromRequest.d.ts +0 -6
- package/node/utils/request/onUnhandledRequest.d.ts +0 -5
- package/node/utils/request/parseBody.d.ts +0 -5
package/lib/esm/graphql.js
CHANGED
|
@@ -1,155 +1,20 @@
|
|
|
1
1
|
import { a as set, s as status, d as delay, f as fetch } from './fetch-deps.js';
|
|
2
2
|
import { d as data, e as errors } from './errors-deps.js';
|
|
3
|
-
import { j as jsonParse, m as matchRequestUrl,
|
|
4
|
-
|
|
5
|
-
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
6
|
-
var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
|
|
3
|
+
import { j as jsonParse, m as matchRequestUrl, b as prepareRequest, c as prepareResponse, d as getTimestamp, e as getStatusCodeColor, a as getCallFrame } from './getCallFrame-deps.js';
|
|
7
4
|
|
|
8
5
|
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
|
-
var MAX_ARRAY_LENGTH = 10;
|
|
10
|
-
var MAX_RECURSIVE_DEPTH = 2;
|
|
11
|
-
/**
|
|
12
|
-
* Used to print values in error messages.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
function inspect(value) {
|
|
16
|
-
return formatValue(value, []);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function formatValue(value, seenValues) {
|
|
20
|
-
switch (_typeof(value)) {
|
|
21
|
-
case 'string':
|
|
22
|
-
return JSON.stringify(value);
|
|
23
|
-
|
|
24
|
-
case 'function':
|
|
25
|
-
return value.name ? "[function ".concat(value.name, "]") : '[function]';
|
|
26
|
-
|
|
27
|
-
case 'object':
|
|
28
|
-
if (value === null) {
|
|
29
|
-
return 'null';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return formatObjectValue(value, seenValues);
|
|
33
|
-
|
|
34
|
-
default:
|
|
35
|
-
return String(value);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function formatObjectValue(value, previouslySeenValues) {
|
|
40
|
-
if (previouslySeenValues.indexOf(value) !== -1) {
|
|
41
|
-
return '[Circular]';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var seenValues = [].concat(previouslySeenValues, [value]);
|
|
45
|
-
var customInspectFn = getCustomFn(value);
|
|
46
|
-
|
|
47
|
-
if (customInspectFn !== undefined) {
|
|
48
|
-
// $FlowFixMe(>=0.90.0)
|
|
49
|
-
var customValue = customInspectFn.call(value); // check for infinite recursion
|
|
50
|
-
|
|
51
|
-
if (customValue !== value) {
|
|
52
|
-
return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
|
|
53
|
-
}
|
|
54
|
-
} else if (Array.isArray(value)) {
|
|
55
|
-
return formatArray(value, seenValues);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return formatObject(value, seenValues);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function formatObject(object, seenValues) {
|
|
62
|
-
var keys = Object.keys(object);
|
|
63
|
-
|
|
64
|
-
if (keys.length === 0) {
|
|
65
|
-
return '{}';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
69
|
-
return '[' + getObjectTag(object) + ']';
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
var properties = keys.map(function (key) {
|
|
73
|
-
var value = formatValue(object[key], seenValues);
|
|
74
|
-
return key + ': ' + value;
|
|
75
|
-
});
|
|
76
|
-
return '{ ' + properties.join(', ') + ' }';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function formatArray(array, seenValues) {
|
|
80
|
-
if (array.length === 0) {
|
|
81
|
-
return '[]';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
85
|
-
return '[Array]';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
var len = Math.min(MAX_ARRAY_LENGTH, array.length);
|
|
89
|
-
var remaining = array.length - len;
|
|
90
|
-
var items = [];
|
|
91
|
-
|
|
92
|
-
for (var i = 0; i < len; ++i) {
|
|
93
|
-
items.push(formatValue(array[i], seenValues));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (remaining === 1) {
|
|
97
|
-
items.push('... 1 more item');
|
|
98
|
-
} else if (remaining > 1) {
|
|
99
|
-
items.push("... ".concat(remaining, " more items"));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return '[' + items.join(', ') + ']';
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function getCustomFn(object) {
|
|
106
|
-
var customInspectFn = object[String(nodejsCustomInspectSymbol)];
|
|
107
|
-
|
|
108
|
-
if (typeof customInspectFn === 'function') {
|
|
109
|
-
return customInspectFn;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (typeof object.inspect === 'function') {
|
|
113
|
-
return object.inspect;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function getObjectTag(object) {
|
|
118
|
-
var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
|
|
119
|
-
|
|
120
|
-
if (tag === 'Object' && typeof object.constructor === 'function') {
|
|
121
|
-
var name = object.constructor.name;
|
|
122
|
-
|
|
123
|
-
if (typeof name === 'string' && name !== '') {
|
|
124
|
-
return name;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return tag;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function devAssert(condition, message) {
|
|
132
|
-
var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
|
|
133
|
-
|
|
134
|
-
if (!booleanCondition) {
|
|
135
|
-
throw new Error(message);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
|
|
140
6
|
|
|
141
7
|
/**
|
|
142
8
|
* Return true if `value` is object-like. A value is object-like if it's not
|
|
143
9
|
* `null` and has a `typeof` result of "object".
|
|
144
10
|
*/
|
|
145
11
|
function isObjectLike(value) {
|
|
146
|
-
return _typeof
|
|
12
|
+
return _typeof(value) == 'object' && value !== null;
|
|
147
13
|
}
|
|
148
14
|
|
|
149
15
|
// In ES2015 (or a polyfilled) environment, this will be Symbol.iterator
|
|
150
16
|
|
|
151
|
-
var SYMBOL_TO_STRING_TAG =
|
|
152
|
-
typeof Symbol === 'function' ? Symbol.toStringTag : '@@toStringTag';
|
|
17
|
+
var SYMBOL_TO_STRING_TAG = typeof Symbol === 'function' && Symbol.toStringTag != null ? Symbol.toStringTag : '@@toStringTag';
|
|
153
18
|
|
|
154
19
|
/**
|
|
155
20
|
* Represents a location in a Source.
|
|
@@ -242,7 +107,7 @@ function leftPad(len, str) {
|
|
|
242
107
|
return whitespace(len - str.length) + str;
|
|
243
108
|
}
|
|
244
109
|
|
|
245
|
-
function _typeof$
|
|
110
|
+
function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
|
|
246
111
|
|
|
247
112
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
248
113
|
|
|
@@ -254,7 +119,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
254
119
|
|
|
255
120
|
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); }; }
|
|
256
121
|
|
|
257
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof$
|
|
122
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof$1(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
258
123
|
|
|
259
124
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
260
125
|
|
|
@@ -473,7 +338,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
473
338
|
value: function toString() {
|
|
474
339
|
return printError(this);
|
|
475
340
|
} // FIXME: workaround to not break chai comparisons, should be remove in v16
|
|
476
|
-
// $FlowFixMe Flow doesn't support computed properties yet
|
|
341
|
+
// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
|
|
477
342
|
|
|
478
343
|
}, {
|
|
479
344
|
key: SYMBOL_TO_STRING_TAG,
|
|
@@ -590,6 +455,9 @@ function invariant(condition, message) {
|
|
|
590
455
|
}
|
|
591
456
|
}
|
|
592
457
|
|
|
458
|
+
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
459
|
+
var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
|
|
460
|
+
|
|
593
461
|
/**
|
|
594
462
|
* The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
|
|
595
463
|
*/
|
|
@@ -679,40 +547,230 @@ var Token = /*#__PURE__*/function () {
|
|
|
679
547
|
* For non-punctuation tokens, represents the interpreted value of the token.
|
|
680
548
|
*/
|
|
681
549
|
|
|
682
|
-
/**
|
|
683
|
-
* Tokens exist as nodes in a double-linked-list amongst all tokens
|
|
684
|
-
* including ignored tokens. <SOF> is always the first node and <EOF>
|
|
685
|
-
* the last.
|
|
686
|
-
*/
|
|
687
|
-
function Token(kind, start, end, line, column, prev, value) {
|
|
688
|
-
this.kind = kind;
|
|
689
|
-
this.start = start;
|
|
690
|
-
this.end = end;
|
|
691
|
-
this.line = line;
|
|
692
|
-
this.column = column;
|
|
693
|
-
this.value = value;
|
|
694
|
-
this.prev = prev;
|
|
695
|
-
this.next = null;
|
|
550
|
+
/**
|
|
551
|
+
* Tokens exist as nodes in a double-linked-list amongst all tokens
|
|
552
|
+
* including ignored tokens. <SOF> is always the first node and <EOF>
|
|
553
|
+
* the last.
|
|
554
|
+
*/
|
|
555
|
+
function Token(kind, start, end, line, column, prev, value) {
|
|
556
|
+
this.kind = kind;
|
|
557
|
+
this.start = start;
|
|
558
|
+
this.end = end;
|
|
559
|
+
this.line = line;
|
|
560
|
+
this.column = column;
|
|
561
|
+
this.value = value;
|
|
562
|
+
this.prev = prev;
|
|
563
|
+
this.next = null;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
var _proto2 = Token.prototype;
|
|
567
|
+
|
|
568
|
+
_proto2.toJSON = function toJSON() {
|
|
569
|
+
return {
|
|
570
|
+
kind: this.kind,
|
|
571
|
+
value: this.value,
|
|
572
|
+
line: this.line,
|
|
573
|
+
column: this.column
|
|
574
|
+
};
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
return Token;
|
|
578
|
+
}(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
|
|
579
|
+
|
|
580
|
+
defineInspect(Token);
|
|
581
|
+
/**
|
|
582
|
+
* The list of all possible AST node types.
|
|
583
|
+
*/
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* An exported enum describing the different kinds of tokens that the
|
|
587
|
+
* lexer emits.
|
|
588
|
+
*/
|
|
589
|
+
var TokenKind = Object.freeze({
|
|
590
|
+
SOF: '<SOF>',
|
|
591
|
+
EOF: '<EOF>',
|
|
592
|
+
BANG: '!',
|
|
593
|
+
DOLLAR: '$',
|
|
594
|
+
AMP: '&',
|
|
595
|
+
PAREN_L: '(',
|
|
596
|
+
PAREN_R: ')',
|
|
597
|
+
SPREAD: '...',
|
|
598
|
+
COLON: ':',
|
|
599
|
+
EQUALS: '=',
|
|
600
|
+
AT: '@',
|
|
601
|
+
BRACKET_L: '[',
|
|
602
|
+
BRACKET_R: ']',
|
|
603
|
+
BRACE_L: '{',
|
|
604
|
+
PIPE: '|',
|
|
605
|
+
BRACE_R: '}',
|
|
606
|
+
NAME: 'Name',
|
|
607
|
+
INT: 'Int',
|
|
608
|
+
FLOAT: 'Float',
|
|
609
|
+
STRING: 'String',
|
|
610
|
+
BLOCK_STRING: 'BlockString',
|
|
611
|
+
COMMENT: 'Comment'
|
|
612
|
+
});
|
|
613
|
+
/**
|
|
614
|
+
* The enum type representing the token kinds values.
|
|
615
|
+
*/
|
|
616
|
+
|
|
617
|
+
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); }
|
|
618
|
+
var MAX_ARRAY_LENGTH = 10;
|
|
619
|
+
var MAX_RECURSIVE_DEPTH = 2;
|
|
620
|
+
/**
|
|
621
|
+
* Used to print values in error messages.
|
|
622
|
+
*/
|
|
623
|
+
|
|
624
|
+
function inspect(value) {
|
|
625
|
+
return formatValue(value, []);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function formatValue(value, seenValues) {
|
|
629
|
+
switch (_typeof$2(value)) {
|
|
630
|
+
case 'string':
|
|
631
|
+
return JSON.stringify(value);
|
|
632
|
+
|
|
633
|
+
case 'function':
|
|
634
|
+
return value.name ? "[function ".concat(value.name, "]") : '[function]';
|
|
635
|
+
|
|
636
|
+
case 'object':
|
|
637
|
+
if (value === null) {
|
|
638
|
+
return 'null';
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
return formatObjectValue(value, seenValues);
|
|
642
|
+
|
|
643
|
+
default:
|
|
644
|
+
return String(value);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
function formatObjectValue(value, previouslySeenValues) {
|
|
649
|
+
if (previouslySeenValues.indexOf(value) !== -1) {
|
|
650
|
+
return '[Circular]';
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
var seenValues = [].concat(previouslySeenValues, [value]);
|
|
654
|
+
var customInspectFn = getCustomFn(value);
|
|
655
|
+
|
|
656
|
+
if (customInspectFn !== undefined) {
|
|
657
|
+
var customValue = customInspectFn.call(value); // check for infinite recursion
|
|
658
|
+
|
|
659
|
+
if (customValue !== value) {
|
|
660
|
+
return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
|
|
661
|
+
}
|
|
662
|
+
} else if (Array.isArray(value)) {
|
|
663
|
+
return formatArray(value, seenValues);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
return formatObject(value, seenValues);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function formatObject(object, seenValues) {
|
|
670
|
+
var keys = Object.keys(object);
|
|
671
|
+
|
|
672
|
+
if (keys.length === 0) {
|
|
673
|
+
return '{}';
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
677
|
+
return '[' + getObjectTag(object) + ']';
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
var properties = keys.map(function (key) {
|
|
681
|
+
var value = formatValue(object[key], seenValues);
|
|
682
|
+
return key + ': ' + value;
|
|
683
|
+
});
|
|
684
|
+
return '{ ' + properties.join(', ') + ' }';
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function formatArray(array, seenValues) {
|
|
688
|
+
if (array.length === 0) {
|
|
689
|
+
return '[]';
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
693
|
+
return '[Array]';
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
var len = Math.min(MAX_ARRAY_LENGTH, array.length);
|
|
697
|
+
var remaining = array.length - len;
|
|
698
|
+
var items = [];
|
|
699
|
+
|
|
700
|
+
for (var i = 0; i < len; ++i) {
|
|
701
|
+
items.push(formatValue(array[i], seenValues));
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (remaining === 1) {
|
|
705
|
+
items.push('... 1 more item');
|
|
706
|
+
} else if (remaining > 1) {
|
|
707
|
+
items.push("... ".concat(remaining, " more items"));
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
return '[' + items.join(', ') + ']';
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function getCustomFn(object) {
|
|
714
|
+
var customInspectFn = object[String(nodejsCustomInspectSymbol)];
|
|
715
|
+
|
|
716
|
+
if (typeof customInspectFn === 'function') {
|
|
717
|
+
return customInspectFn;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (typeof object.inspect === 'function') {
|
|
721
|
+
return object.inspect;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function getObjectTag(object) {
|
|
726
|
+
var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
|
|
727
|
+
|
|
728
|
+
if (tag === 'Object' && typeof object.constructor === 'function') {
|
|
729
|
+
var name = object.constructor.name;
|
|
730
|
+
|
|
731
|
+
if (typeof name === 'string' && name !== '') {
|
|
732
|
+
return name;
|
|
733
|
+
}
|
|
696
734
|
}
|
|
697
735
|
|
|
698
|
-
|
|
736
|
+
return tag;
|
|
737
|
+
}
|
|
699
738
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
kind: this.kind,
|
|
703
|
-
value: this.value,
|
|
704
|
-
line: this.line,
|
|
705
|
-
column: this.column
|
|
706
|
-
};
|
|
707
|
-
};
|
|
739
|
+
function devAssert(condition, message) {
|
|
740
|
+
var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
|
|
708
741
|
|
|
709
|
-
|
|
710
|
-
|
|
742
|
+
if (!booleanCondition) {
|
|
743
|
+
throw new Error(message);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
711
746
|
|
|
712
|
-
defineInspect(Token);
|
|
713
747
|
/**
|
|
714
|
-
*
|
|
748
|
+
* A replacement for instanceof which includes an error warning when multi-realm
|
|
749
|
+
* constructors are detected.
|
|
715
750
|
*/
|
|
751
|
+
// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
|
|
752
|
+
// See: https://webpack.js.org/guides/production/
|
|
753
|
+
var instanceOf = process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
754
|
+
// eslint-disable-next-line no-shadow
|
|
755
|
+
function instanceOf(value, constructor) {
|
|
756
|
+
return value instanceof constructor;
|
|
757
|
+
} : // eslint-disable-next-line no-shadow
|
|
758
|
+
function instanceOf(value, constructor) {
|
|
759
|
+
if (value instanceof constructor) {
|
|
760
|
+
return true;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
if (value) {
|
|
764
|
+
var valueClass = value.constructor;
|
|
765
|
+
var className = constructor.name;
|
|
766
|
+
|
|
767
|
+
if (className && valueClass && valueClass.name === className) {
|
|
768
|
+
throw new Error("Cannot use ".concat(className, " \"").concat(value, "\" 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."));
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
return false;
|
|
773
|
+
};
|
|
716
774
|
|
|
717
775
|
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); } }
|
|
718
776
|
|
|
@@ -732,12 +790,13 @@ var Source = /*#__PURE__*/function () {
|
|
|
732
790
|
line: 1,
|
|
733
791
|
column: 1
|
|
734
792
|
};
|
|
793
|
+
typeof body === 'string' || devAssert(0, "Body must be a string. Received: ".concat(inspect(body), "."));
|
|
735
794
|
this.body = body;
|
|
736
795
|
this.name = name;
|
|
737
796
|
this.locationOffset = locationOffset;
|
|
738
797
|
this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.');
|
|
739
798
|
this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.');
|
|
740
|
-
} // $FlowFixMe Flow doesn't support computed properties yet
|
|
799
|
+
} // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
|
|
741
800
|
|
|
742
801
|
|
|
743
802
|
_createClass$1(Source, [{
|
|
@@ -749,39 +808,17 @@ var Source = /*#__PURE__*/function () {
|
|
|
749
808
|
|
|
750
809
|
return Source;
|
|
751
810
|
}();
|
|
752
|
-
|
|
753
|
-
/**
|
|
754
|
-
* An exported enum describing the different kinds of tokens that the
|
|
755
|
-
* lexer emits.
|
|
756
|
-
*/
|
|
757
|
-
var TokenKind = Object.freeze({
|
|
758
|
-
SOF: '<SOF>',
|
|
759
|
-
EOF: '<EOF>',
|
|
760
|
-
BANG: '!',
|
|
761
|
-
DOLLAR: '$',
|
|
762
|
-
AMP: '&',
|
|
763
|
-
PAREN_L: '(',
|
|
764
|
-
PAREN_R: ')',
|
|
765
|
-
SPREAD: '...',
|
|
766
|
-
COLON: ':',
|
|
767
|
-
EQUALS: '=',
|
|
768
|
-
AT: '@',
|
|
769
|
-
BRACKET_L: '[',
|
|
770
|
-
BRACKET_R: ']',
|
|
771
|
-
BRACE_L: '{',
|
|
772
|
-
PIPE: '|',
|
|
773
|
-
BRACE_R: '}',
|
|
774
|
-
NAME: 'Name',
|
|
775
|
-
INT: 'Int',
|
|
776
|
-
FLOAT: 'Float',
|
|
777
|
-
STRING: 'String',
|
|
778
|
-
BLOCK_STRING: 'BlockString',
|
|
779
|
-
COMMENT: 'Comment'
|
|
780
|
-
});
|
|
781
811
|
/**
|
|
782
|
-
*
|
|
812
|
+
* Test if the given value is a Source object.
|
|
813
|
+
*
|
|
814
|
+
* @internal
|
|
783
815
|
*/
|
|
784
816
|
|
|
817
|
+
// eslint-disable-next-line no-redeclare
|
|
818
|
+
function isSource(source) {
|
|
819
|
+
return instanceOf(source, Source);
|
|
820
|
+
}
|
|
821
|
+
|
|
785
822
|
/**
|
|
786
823
|
* The set of allowed directive location values.
|
|
787
824
|
*/
|
|
@@ -824,7 +861,7 @@ function dedentBlockStringValue(rawString) {
|
|
|
824
861
|
// Expand a block string's raw value into independent lines.
|
|
825
862
|
var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
|
|
826
863
|
|
|
827
|
-
var commonIndent = getBlockStringIndentation(
|
|
864
|
+
var commonIndent = getBlockStringIndentation(rawString);
|
|
828
865
|
|
|
829
866
|
if (commonIndent !== 0) {
|
|
830
867
|
for (var i = 1; i < lines.length; i++) {
|
|
@@ -833,56 +870,78 @@ function dedentBlockStringValue(rawString) {
|
|
|
833
870
|
} // Remove leading and trailing blank lines.
|
|
834
871
|
|
|
835
872
|
|
|
836
|
-
|
|
837
|
-
|
|
873
|
+
var startLine = 0;
|
|
874
|
+
|
|
875
|
+
while (startLine < lines.length && isBlank(lines[startLine])) {
|
|
876
|
+
++startLine;
|
|
838
877
|
}
|
|
839
878
|
|
|
840
|
-
|
|
841
|
-
|
|
879
|
+
var endLine = lines.length;
|
|
880
|
+
|
|
881
|
+
while (endLine > startLine && isBlank(lines[endLine - 1])) {
|
|
882
|
+
--endLine;
|
|
842
883
|
} // Return a string of the lines joined with U+000A.
|
|
843
884
|
|
|
844
885
|
|
|
845
|
-
return lines.join('\n');
|
|
886
|
+
return lines.slice(startLine, endLine).join('\n');
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
function isBlank(str) {
|
|
890
|
+
for (var i = 0; i < str.length; ++i) {
|
|
891
|
+
if (str[i] !== ' ' && str[i] !== '\t') {
|
|
892
|
+
return false;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
return true;
|
|
846
897
|
}
|
|
847
898
|
/**
|
|
848
899
|
* @internal
|
|
849
900
|
*/
|
|
850
901
|
|
|
851
|
-
function getBlockStringIndentation(lines) {
|
|
852
|
-
var commonIndent = null;
|
|
853
902
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
var indent = leadingWhitespace(line);
|
|
903
|
+
function getBlockStringIndentation(value) {
|
|
904
|
+
var _commonIndent;
|
|
857
905
|
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
906
|
+
var isFirstLine = true;
|
|
907
|
+
var isEmptyLine = true;
|
|
908
|
+
var indent = 0;
|
|
909
|
+
var commonIndent = null;
|
|
910
|
+
|
|
911
|
+
for (var i = 0; i < value.length; ++i) {
|
|
912
|
+
switch (value.charCodeAt(i)) {
|
|
913
|
+
case 13:
|
|
914
|
+
// \r
|
|
915
|
+
if (value.charCodeAt(i + 1) === 10) {
|
|
916
|
+
++i; // skip \r\n as one symbol
|
|
917
|
+
}
|
|
861
918
|
|
|
862
|
-
|
|
863
|
-
commonIndent = indent;
|
|
919
|
+
// falls through
|
|
864
920
|
|
|
865
|
-
|
|
921
|
+
case 10:
|
|
922
|
+
// \n
|
|
923
|
+
isFirstLine = false;
|
|
924
|
+
isEmptyLine = true;
|
|
925
|
+
indent = 0;
|
|
866
926
|
break;
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
927
|
|
|
871
|
-
|
|
872
|
-
}
|
|
928
|
+
case 9: // \t
|
|
873
929
|
|
|
874
|
-
|
|
875
|
-
|
|
930
|
+
case 32:
|
|
931
|
+
// <space>
|
|
932
|
+
++indent;
|
|
933
|
+
break;
|
|
876
934
|
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
935
|
+
default:
|
|
936
|
+
if (isEmptyLine && !isFirstLine && (commonIndent === null || indent < commonIndent)) {
|
|
937
|
+
commonIndent = indent;
|
|
938
|
+
}
|
|
880
939
|
|
|
881
|
-
|
|
882
|
-
}
|
|
940
|
+
isEmptyLine = false;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
883
943
|
|
|
884
|
-
|
|
885
|
-
return leadingWhitespace(str) === str.length;
|
|
944
|
+
return (_commonIndent = commonIndent) !== null && _commonIndent !== void 0 ? _commonIndent : 0;
|
|
886
945
|
}
|
|
887
946
|
|
|
888
947
|
/**
|
|
@@ -981,161 +1040,257 @@ function readToken(lexer, prev) {
|
|
|
981
1040
|
var source = lexer.source;
|
|
982
1041
|
var body = source.body;
|
|
983
1042
|
var bodyLength = body.length;
|
|
984
|
-
var pos =
|
|
985
|
-
var line = lexer.line;
|
|
986
|
-
var col = 1 + pos - lexer.lineStart;
|
|
1043
|
+
var pos = prev.end;
|
|
987
1044
|
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1045
|
+
while (pos < bodyLength) {
|
|
1046
|
+
var code = body.charCodeAt(pos);
|
|
1047
|
+
var _line = lexer.line;
|
|
991
1048
|
|
|
992
|
-
|
|
1049
|
+
var _col = 1 + pos - lexer.lineStart; // SourceCharacter
|
|
993
1050
|
|
|
994
|
-
switch (code) {
|
|
995
|
-
// !
|
|
996
|
-
case 33:
|
|
997
|
-
return new Token(TokenKind.BANG, pos, pos + 1, line, col, prev);
|
|
998
|
-
// #
|
|
999
1051
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
// $
|
|
1052
|
+
switch (code) {
|
|
1053
|
+
case 0xfeff: // <BOM>
|
|
1003
1054
|
|
|
1004
|
-
|
|
1005
|
-
return new Token(TokenKind.DOLLAR, pos, pos + 1, line, col, prev);
|
|
1006
|
-
// &
|
|
1055
|
+
case 9: // \t
|
|
1007
1056
|
|
|
1008
|
-
|
|
1009
|
-
return new Token(TokenKind.AMP, pos, pos + 1, line, col, prev);
|
|
1010
|
-
// (
|
|
1057
|
+
case 32: // <space>
|
|
1011
1058
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1059
|
+
case 44:
|
|
1060
|
+
// ,
|
|
1061
|
+
++pos;
|
|
1062
|
+
continue;
|
|
1015
1063
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1064
|
+
case 10:
|
|
1065
|
+
// \n
|
|
1066
|
+
++pos;
|
|
1067
|
+
++lexer.line;
|
|
1068
|
+
lexer.lineStart = pos;
|
|
1069
|
+
continue;
|
|
1019
1070
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1071
|
+
case 13:
|
|
1072
|
+
// \r
|
|
1073
|
+
if (body.charCodeAt(pos + 1) === 10) {
|
|
1074
|
+
pos += 2;
|
|
1075
|
+
} else {
|
|
1076
|
+
++pos;
|
|
1077
|
+
}
|
|
1024
1078
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
case 112:
|
|
1103
|
-
case 113:
|
|
1104
|
-
case 114:
|
|
1105
|
-
case 115:
|
|
1106
|
-
case 116:
|
|
1107
|
-
case 117:
|
|
1108
|
-
case 118:
|
|
1109
|
-
case 119:
|
|
1110
|
-
case 120:
|
|
1111
|
-
case 121:
|
|
1112
|
-
case 122:
|
|
1113
|
-
return readName(source, pos, line, col, prev);
|
|
1114
|
-
// - 0-9
|
|
1115
|
-
|
|
1116
|
-
case 45:
|
|
1117
|
-
case 48:
|
|
1118
|
-
case 49:
|
|
1119
|
-
case 50:
|
|
1120
|
-
case 51:
|
|
1121
|
-
case 52:
|
|
1122
|
-
case 53:
|
|
1123
|
-
case 54:
|
|
1124
|
-
case 55:
|
|
1125
|
-
case 56:
|
|
1126
|
-
case 57:
|
|
1127
|
-
return readNumber(source, pos, code, line, col, prev);
|
|
1128
|
-
// "
|
|
1129
|
-
|
|
1130
|
-
case 34:
|
|
1131
|
-
if (body.charCodeAt(pos + 1) === 34 && body.charCodeAt(pos + 2) === 34) {
|
|
1132
|
-
return readBlockString(source, pos, line, col, prev, lexer);
|
|
1133
|
-
}
|
|
1079
|
+
++lexer.line;
|
|
1080
|
+
lexer.lineStart = pos;
|
|
1081
|
+
continue;
|
|
1082
|
+
|
|
1083
|
+
case 33:
|
|
1084
|
+
// !
|
|
1085
|
+
return new Token(TokenKind.BANG, pos, pos + 1, _line, _col, prev);
|
|
1086
|
+
|
|
1087
|
+
case 35:
|
|
1088
|
+
// #
|
|
1089
|
+
return readComment(source, pos, _line, _col, prev);
|
|
1090
|
+
|
|
1091
|
+
case 36:
|
|
1092
|
+
// $
|
|
1093
|
+
return new Token(TokenKind.DOLLAR, pos, pos + 1, _line, _col, prev);
|
|
1094
|
+
|
|
1095
|
+
case 38:
|
|
1096
|
+
// &
|
|
1097
|
+
return new Token(TokenKind.AMP, pos, pos + 1, _line, _col, prev);
|
|
1098
|
+
|
|
1099
|
+
case 40:
|
|
1100
|
+
// (
|
|
1101
|
+
return new Token(TokenKind.PAREN_L, pos, pos + 1, _line, _col, prev);
|
|
1102
|
+
|
|
1103
|
+
case 41:
|
|
1104
|
+
// )
|
|
1105
|
+
return new Token(TokenKind.PAREN_R, pos, pos + 1, _line, _col, prev);
|
|
1106
|
+
|
|
1107
|
+
case 46:
|
|
1108
|
+
// .
|
|
1109
|
+
if (body.charCodeAt(pos + 1) === 46 && body.charCodeAt(pos + 2) === 46) {
|
|
1110
|
+
return new Token(TokenKind.SPREAD, pos, pos + 3, _line, _col, prev);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
break;
|
|
1114
|
+
|
|
1115
|
+
case 58:
|
|
1116
|
+
// :
|
|
1117
|
+
return new Token(TokenKind.COLON, pos, pos + 1, _line, _col, prev);
|
|
1118
|
+
|
|
1119
|
+
case 61:
|
|
1120
|
+
// =
|
|
1121
|
+
return new Token(TokenKind.EQUALS, pos, pos + 1, _line, _col, prev);
|
|
1122
|
+
|
|
1123
|
+
case 64:
|
|
1124
|
+
// @
|
|
1125
|
+
return new Token(TokenKind.AT, pos, pos + 1, _line, _col, prev);
|
|
1126
|
+
|
|
1127
|
+
case 91:
|
|
1128
|
+
// [
|
|
1129
|
+
return new Token(TokenKind.BRACKET_L, pos, pos + 1, _line, _col, prev);
|
|
1130
|
+
|
|
1131
|
+
case 93:
|
|
1132
|
+
// ]
|
|
1133
|
+
return new Token(TokenKind.BRACKET_R, pos, pos + 1, _line, _col, prev);
|
|
1134
|
+
|
|
1135
|
+
case 123:
|
|
1136
|
+
// {
|
|
1137
|
+
return new Token(TokenKind.BRACE_L, pos, pos + 1, _line, _col, prev);
|
|
1138
|
+
|
|
1139
|
+
case 124:
|
|
1140
|
+
// |
|
|
1141
|
+
return new Token(TokenKind.PIPE, pos, pos + 1, _line, _col, prev);
|
|
1142
|
+
|
|
1143
|
+
case 125:
|
|
1144
|
+
// }
|
|
1145
|
+
return new Token(TokenKind.BRACE_R, pos, pos + 1, _line, _col, prev);
|
|
1146
|
+
|
|
1147
|
+
case 34:
|
|
1148
|
+
// "
|
|
1149
|
+
if (body.charCodeAt(pos + 1) === 34 && body.charCodeAt(pos + 2) === 34) {
|
|
1150
|
+
return readBlockString(source, pos, _line, _col, prev, lexer);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
return readString(source, pos, _line, _col, prev);
|
|
1154
|
+
|
|
1155
|
+
case 45: // -
|
|
1134
1156
|
|
|
1135
|
-
|
|
1157
|
+
case 48: // 0
|
|
1158
|
+
|
|
1159
|
+
case 49: // 1
|
|
1160
|
+
|
|
1161
|
+
case 50: // 2
|
|
1162
|
+
|
|
1163
|
+
case 51: // 3
|
|
1164
|
+
|
|
1165
|
+
case 52: // 4
|
|
1166
|
+
|
|
1167
|
+
case 53: // 5
|
|
1168
|
+
|
|
1169
|
+
case 54: // 6
|
|
1170
|
+
|
|
1171
|
+
case 55: // 7
|
|
1172
|
+
|
|
1173
|
+
case 56: // 8
|
|
1174
|
+
|
|
1175
|
+
case 57:
|
|
1176
|
+
// 9
|
|
1177
|
+
return readNumber(source, pos, code, _line, _col, prev);
|
|
1178
|
+
|
|
1179
|
+
case 65: // A
|
|
1180
|
+
|
|
1181
|
+
case 66: // B
|
|
1182
|
+
|
|
1183
|
+
case 67: // C
|
|
1184
|
+
|
|
1185
|
+
case 68: // D
|
|
1186
|
+
|
|
1187
|
+
case 69: // E
|
|
1188
|
+
|
|
1189
|
+
case 70: // F
|
|
1190
|
+
|
|
1191
|
+
case 71: // G
|
|
1192
|
+
|
|
1193
|
+
case 72: // H
|
|
1194
|
+
|
|
1195
|
+
case 73: // I
|
|
1196
|
+
|
|
1197
|
+
case 74: // J
|
|
1198
|
+
|
|
1199
|
+
case 75: // K
|
|
1200
|
+
|
|
1201
|
+
case 76: // L
|
|
1202
|
+
|
|
1203
|
+
case 77: // M
|
|
1204
|
+
|
|
1205
|
+
case 78: // N
|
|
1206
|
+
|
|
1207
|
+
case 79: // O
|
|
1208
|
+
|
|
1209
|
+
case 80: // P
|
|
1210
|
+
|
|
1211
|
+
case 81: // Q
|
|
1212
|
+
|
|
1213
|
+
case 82: // R
|
|
1214
|
+
|
|
1215
|
+
case 83: // S
|
|
1216
|
+
|
|
1217
|
+
case 84: // T
|
|
1218
|
+
|
|
1219
|
+
case 85: // U
|
|
1220
|
+
|
|
1221
|
+
case 86: // V
|
|
1222
|
+
|
|
1223
|
+
case 87: // W
|
|
1224
|
+
|
|
1225
|
+
case 88: // X
|
|
1226
|
+
|
|
1227
|
+
case 89: // Y
|
|
1228
|
+
|
|
1229
|
+
case 90: // Z
|
|
1230
|
+
|
|
1231
|
+
case 95: // _
|
|
1232
|
+
|
|
1233
|
+
case 97: // a
|
|
1234
|
+
|
|
1235
|
+
case 98: // b
|
|
1236
|
+
|
|
1237
|
+
case 99: // c
|
|
1238
|
+
|
|
1239
|
+
case 100: // d
|
|
1240
|
+
|
|
1241
|
+
case 101: // e
|
|
1242
|
+
|
|
1243
|
+
case 102: // f
|
|
1244
|
+
|
|
1245
|
+
case 103: // g
|
|
1246
|
+
|
|
1247
|
+
case 104: // h
|
|
1248
|
+
|
|
1249
|
+
case 105: // i
|
|
1250
|
+
|
|
1251
|
+
case 106: // j
|
|
1252
|
+
|
|
1253
|
+
case 107: // k
|
|
1254
|
+
|
|
1255
|
+
case 108: // l
|
|
1256
|
+
|
|
1257
|
+
case 109: // m
|
|
1258
|
+
|
|
1259
|
+
case 110: // n
|
|
1260
|
+
|
|
1261
|
+
case 111: // o
|
|
1262
|
+
|
|
1263
|
+
case 112: // p
|
|
1264
|
+
|
|
1265
|
+
case 113: // q
|
|
1266
|
+
|
|
1267
|
+
case 114: // r
|
|
1268
|
+
|
|
1269
|
+
case 115: // s
|
|
1270
|
+
|
|
1271
|
+
case 116: // t
|
|
1272
|
+
|
|
1273
|
+
case 117: // u
|
|
1274
|
+
|
|
1275
|
+
case 118: // v
|
|
1276
|
+
|
|
1277
|
+
case 119: // w
|
|
1278
|
+
|
|
1279
|
+
case 120: // x
|
|
1280
|
+
|
|
1281
|
+
case 121: // y
|
|
1282
|
+
|
|
1283
|
+
case 122:
|
|
1284
|
+
// z
|
|
1285
|
+
return readName(source, pos, _line, _col, prev);
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
throw syntaxError(source, pos, unexpectedCharacterMessage(code));
|
|
1136
1289
|
}
|
|
1137
1290
|
|
|
1138
|
-
|
|
1291
|
+
var line = lexer.line;
|
|
1292
|
+
var col = 1 + pos - lexer.lineStart;
|
|
1293
|
+
return new Token(TokenKind.EOF, bodyLength, bodyLength, line, col, prev);
|
|
1139
1294
|
}
|
|
1140
1295
|
/**
|
|
1141
1296
|
* Report a message that an unexpected character was encountered.
|
|
@@ -1154,43 +1309,6 @@ function unexpectedCharacterMessage(code) {
|
|
|
1154
1309
|
|
|
1155
1310
|
return "Cannot parse the unexpected character ".concat(printCharCode(code), ".");
|
|
1156
1311
|
}
|
|
1157
|
-
/**
|
|
1158
|
-
* Reads from body starting at startPosition until it finds a non-whitespace
|
|
1159
|
-
* character, then returns the position of that character for lexing.
|
|
1160
|
-
*/
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
function positionAfterWhitespace(body, startPosition, lexer) {
|
|
1164
|
-
var bodyLength = body.length;
|
|
1165
|
-
var position = startPosition;
|
|
1166
|
-
|
|
1167
|
-
while (position < bodyLength) {
|
|
1168
|
-
var code = body.charCodeAt(position); // tab | space | comma | BOM
|
|
1169
|
-
|
|
1170
|
-
if (code === 9 || code === 32 || code === 44 || code === 0xfeff) {
|
|
1171
|
-
++position;
|
|
1172
|
-
} else if (code === 10) {
|
|
1173
|
-
// new line
|
|
1174
|
-
++position;
|
|
1175
|
-
++lexer.line;
|
|
1176
|
-
lexer.lineStart = position;
|
|
1177
|
-
} else if (code === 13) {
|
|
1178
|
-
// carriage return
|
|
1179
|
-
if (body.charCodeAt(position + 1) === 10) {
|
|
1180
|
-
position += 2;
|
|
1181
|
-
} else {
|
|
1182
|
-
++position;
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
++lexer.line;
|
|
1186
|
-
lexer.lineStart = position;
|
|
1187
|
-
} else {
|
|
1188
|
-
break;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
return position;
|
|
1193
|
-
}
|
|
1194
1312
|
/**
|
|
1195
1313
|
* Reads a comment token from the source file.
|
|
1196
1314
|
*
|
|
@@ -1511,11 +1629,21 @@ function parse(source, options) {
|
|
|
1511
1629
|
var parser = new Parser(source, options);
|
|
1512
1630
|
return parser.parseDocument();
|
|
1513
1631
|
}
|
|
1632
|
+
/**
|
|
1633
|
+
* This class is exported only to assist people in implementing their own parsers
|
|
1634
|
+
* without duplicating too much code and should be used only as last resort for cases
|
|
1635
|
+
* such as experimental syntax or if certain features could not be contributed upstream.
|
|
1636
|
+
*
|
|
1637
|
+
* It is still part of the internal API and is versioned, so any changes to it are never
|
|
1638
|
+
* considered breaking changes. If you still need to support multiple versions of the
|
|
1639
|
+
* library, please use the `versionInfo` variable for version detection.
|
|
1640
|
+
*
|
|
1641
|
+
* @internal
|
|
1642
|
+
*/
|
|
1514
1643
|
|
|
1515
1644
|
var Parser = /*#__PURE__*/function () {
|
|
1516
1645
|
function Parser(source, options) {
|
|
1517
|
-
var sourceObj =
|
|
1518
|
-
sourceObj instanceof Source || devAssert(0, "Must provide Source. Received: ".concat(inspect(sourceObj), "."));
|
|
1646
|
+
var sourceObj = isSource(source) ? source : new Source(source);
|
|
1519
1647
|
this._lexer = new Lexer(sourceObj);
|
|
1520
1648
|
this._options = options;
|
|
1521
1649
|
}
|
|
@@ -2260,21 +2388,25 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2260
2388
|
;
|
|
2261
2389
|
|
|
2262
2390
|
_proto.parseImplementsInterfaces = function parseImplementsInterfaces() {
|
|
2263
|
-
var
|
|
2391
|
+
var _this$_options2;
|
|
2392
|
+
|
|
2393
|
+
if (!this.expectOptionalKeyword('implements')) {
|
|
2394
|
+
return [];
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
if (((_this$_options2 = this._options) === null || _this$_options2 === void 0 ? void 0 : _this$_options2.allowLegacySDLImplementsInterfaces) === true) {
|
|
2398
|
+
var types = []; // Optional leading ampersand
|
|
2264
2399
|
|
|
2265
|
-
if (this.expectOptionalKeyword('implements')) {
|
|
2266
|
-
// Optional leading ampersand
|
|
2267
2400
|
this.expectOptionalToken(TokenKind.AMP);
|
|
2268
2401
|
|
|
2269
2402
|
do {
|
|
2270
|
-
var _this$_options2;
|
|
2271
|
-
|
|
2272
2403
|
types.push(this.parseNamedType());
|
|
2273
|
-
} while (this.expectOptionalToken(TokenKind.AMP) ||
|
|
2274
|
-
|
|
2404
|
+
} while (this.expectOptionalToken(TokenKind.AMP) || this.peek(TokenKind.NAME));
|
|
2405
|
+
|
|
2406
|
+
return types;
|
|
2275
2407
|
}
|
|
2276
2408
|
|
|
2277
|
-
return
|
|
2409
|
+
return this.delimitedMany(TokenKind.AMP, this.parseNamedType);
|
|
2278
2410
|
}
|
|
2279
2411
|
/**
|
|
2280
2412
|
* FieldsDefinition : { FieldDefinition+ }
|
|
@@ -2410,18 +2542,7 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2410
2542
|
;
|
|
2411
2543
|
|
|
2412
2544
|
_proto.parseUnionMemberTypes = function parseUnionMemberTypes() {
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
if (this.expectOptionalToken(TokenKind.EQUALS)) {
|
|
2416
|
-
// Optional leading pipe
|
|
2417
|
-
this.expectOptionalToken(TokenKind.PIPE);
|
|
2418
|
-
|
|
2419
|
-
do {
|
|
2420
|
-
types.push(this.parseNamedType());
|
|
2421
|
-
} while (this.expectOptionalToken(TokenKind.PIPE));
|
|
2422
|
-
}
|
|
2423
|
-
|
|
2424
|
-
return types;
|
|
2545
|
+
return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];
|
|
2425
2546
|
}
|
|
2426
2547
|
/**
|
|
2427
2548
|
* EnumTypeDefinition :
|
|
@@ -2772,15 +2893,7 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2772
2893
|
;
|
|
2773
2894
|
|
|
2774
2895
|
_proto.parseDirectiveLocations = function parseDirectiveLocations() {
|
|
2775
|
-
|
|
2776
|
-
this.expectOptionalToken(TokenKind.PIPE);
|
|
2777
|
-
var locations = [];
|
|
2778
|
-
|
|
2779
|
-
do {
|
|
2780
|
-
locations.push(this.parseDirectiveLocation());
|
|
2781
|
-
} while (this.expectOptionalToken(TokenKind.PIPE));
|
|
2782
|
-
|
|
2783
|
-
return locations;
|
|
2896
|
+
return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
|
|
2784
2897
|
}
|
|
2785
2898
|
/*
|
|
2786
2899
|
* DirectiveLocation :
|
|
@@ -2823,8 +2936,7 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2823
2936
|
} // Core parsing utility functions
|
|
2824
2937
|
|
|
2825
2938
|
/**
|
|
2826
|
-
* Returns a location object, used to identify the place in
|
|
2827
|
-
* the source that created a given parsed object.
|
|
2939
|
+
* Returns a location object, used to identify the place in the source that created a given parsed object.
|
|
2828
2940
|
*/
|
|
2829
2941
|
;
|
|
2830
2942
|
|
|
@@ -2844,8 +2956,8 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2844
2956
|
return this._lexer.token.kind === kind;
|
|
2845
2957
|
}
|
|
2846
2958
|
/**
|
|
2847
|
-
* If the next token is of the given kind, return that token after advancing
|
|
2848
|
-
*
|
|
2959
|
+
* If the next token is of the given kind, return that token after advancing the lexer.
|
|
2960
|
+
* Otherwise, do not change the parser state and throw an error.
|
|
2849
2961
|
*/
|
|
2850
2962
|
;
|
|
2851
2963
|
|
|
@@ -2861,8 +2973,8 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2861
2973
|
throw syntaxError(this._lexer.source, token.start, "Expected ".concat(getTokenKindDesc(kind), ", found ").concat(getTokenDesc(token), "."));
|
|
2862
2974
|
}
|
|
2863
2975
|
/**
|
|
2864
|
-
* If the next token is of the given kind, return that token after advancing
|
|
2865
|
-
*
|
|
2976
|
+
* If the next token is of the given kind, return that token after advancing the lexer.
|
|
2977
|
+
* Otherwise, do not change the parser state and return undefined.
|
|
2866
2978
|
*/
|
|
2867
2979
|
;
|
|
2868
2980
|
|
|
@@ -2893,8 +3005,8 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2893
3005
|
}
|
|
2894
3006
|
}
|
|
2895
3007
|
/**
|
|
2896
|
-
* If the next token is a given keyword, return "true" after advancing
|
|
2897
|
-
*
|
|
3008
|
+
* If the next token is a given keyword, return "true" after advancing the lexer.
|
|
3009
|
+
* Otherwise, do not change the parser state and return "false".
|
|
2898
3010
|
*/
|
|
2899
3011
|
;
|
|
2900
3012
|
|
|
@@ -2910,8 +3022,7 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2910
3022
|
return false;
|
|
2911
3023
|
}
|
|
2912
3024
|
/**
|
|
2913
|
-
* Helper function for creating an error when an unexpected lexed token
|
|
2914
|
-
* is encountered.
|
|
3025
|
+
* Helper function for creating an error when an unexpected lexed token is encountered.
|
|
2915
3026
|
*/
|
|
2916
3027
|
;
|
|
2917
3028
|
|
|
@@ -2920,10 +3031,9 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2920
3031
|
return syntaxError(this._lexer.source, token.start, "Unexpected ".concat(getTokenDesc(token), "."));
|
|
2921
3032
|
}
|
|
2922
3033
|
/**
|
|
2923
|
-
* Returns a possibly empty list of parse nodes, determined by
|
|
2924
|
-
*
|
|
2925
|
-
*
|
|
2926
|
-
* to the next lex token after the closing token.
|
|
3034
|
+
* Returns a possibly empty list of parse nodes, determined by the parseFn.
|
|
3035
|
+
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
3036
|
+
* Advances the parser to the next lex token after the closing token.
|
|
2927
3037
|
*/
|
|
2928
3038
|
;
|
|
2929
3039
|
|
|
@@ -2939,10 +3049,9 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2939
3049
|
}
|
|
2940
3050
|
/**
|
|
2941
3051
|
* Returns a list of parse nodes, determined by the parseFn.
|
|
2942
|
-
* It can be empty only if open token is missing otherwise it will always
|
|
2943
|
-
*
|
|
2944
|
-
*
|
|
2945
|
-
* after the closing token.
|
|
3052
|
+
* It can be empty only if open token is missing otherwise it will always return non-empty list
|
|
3053
|
+
* that begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
3054
|
+
* Advances the parser to the next lex token after the closing token.
|
|
2946
3055
|
*/
|
|
2947
3056
|
;
|
|
2948
3057
|
|
|
@@ -2960,10 +3069,9 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2960
3069
|
return [];
|
|
2961
3070
|
}
|
|
2962
3071
|
/**
|
|
2963
|
-
* Returns a non-empty list of parse nodes, determined by
|
|
2964
|
-
*
|
|
2965
|
-
*
|
|
2966
|
-
* to the next lex token after the closing token.
|
|
3072
|
+
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
3073
|
+
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
3074
|
+
* Advances the parser to the next lex token after the closing token.
|
|
2967
3075
|
*/
|
|
2968
3076
|
;
|
|
2969
3077
|
|
|
@@ -2975,22 +3083,38 @@ var Parser = /*#__PURE__*/function () {
|
|
|
2975
3083
|
nodes.push(parseFn.call(this));
|
|
2976
3084
|
} while (!this.expectOptionalToken(closeKind));
|
|
2977
3085
|
|
|
3086
|
+
return nodes;
|
|
3087
|
+
}
|
|
3088
|
+
/**
|
|
3089
|
+
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
3090
|
+
* This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
|
|
3091
|
+
* Advances the parser to the next lex token after last item in the list.
|
|
3092
|
+
*/
|
|
3093
|
+
;
|
|
3094
|
+
|
|
3095
|
+
_proto.delimitedMany = function delimitedMany(delimiterKind, parseFn) {
|
|
3096
|
+
this.expectOptionalToken(delimiterKind);
|
|
3097
|
+
var nodes = [];
|
|
3098
|
+
|
|
3099
|
+
do {
|
|
3100
|
+
nodes.push(parseFn.call(this));
|
|
3101
|
+
} while (this.expectOptionalToken(delimiterKind));
|
|
3102
|
+
|
|
2978
3103
|
return nodes;
|
|
2979
3104
|
};
|
|
2980
3105
|
|
|
2981
3106
|
return Parser;
|
|
2982
3107
|
}();
|
|
2983
3108
|
/**
|
|
2984
|
-
* A helper function to describe a token as a string for debugging
|
|
3109
|
+
* A helper function to describe a token as a string for debugging.
|
|
2985
3110
|
*/
|
|
2986
3111
|
|
|
2987
|
-
|
|
2988
3112
|
function getTokenDesc(token) {
|
|
2989
3113
|
var value = token.value;
|
|
2990
3114
|
return getTokenKindDesc(token.kind) + (value != null ? " \"".concat(value, "\"") : '');
|
|
2991
3115
|
}
|
|
2992
3116
|
/**
|
|
2993
|
-
* A helper function to describe a token kind as a string for debugging
|
|
3117
|
+
* A helper function to describe a token kind as a string for debugging.
|
|
2994
3118
|
*/
|
|
2995
3119
|
|
|
2996
3120
|
|
|
@@ -3019,6 +3143,7 @@ function parseQuery(query, definitionOperation = 'query') {
|
|
|
3019
3143
|
};
|
|
3020
3144
|
}
|
|
3021
3145
|
function graphQLRequestHandler(expectedOperationType, expectedOperationName, mask, resolver) {
|
|
3146
|
+
const callFrame = getCallFrame();
|
|
3022
3147
|
return {
|
|
3023
3148
|
resolver,
|
|
3024
3149
|
parse(req) {
|
|
@@ -3090,6 +3215,17 @@ function graphQLRequestHandler(expectedOperationType, expectedOperationName, mas
|
|
|
3090
3215
|
console.log('Response:', loggedResponse);
|
|
3091
3216
|
console.groupEnd();
|
|
3092
3217
|
},
|
|
3218
|
+
getMetaInfo() {
|
|
3219
|
+
const header = expectedOperationType === 'all'
|
|
3220
|
+
? `[graphql] ${expectedOperationType} (origin: ${mask.toString()})`
|
|
3221
|
+
: `[graphql] ${expectedOperationType} ${expectedOperationName} (origin: ${mask.toString()})`;
|
|
3222
|
+
return {
|
|
3223
|
+
type: 'graphql',
|
|
3224
|
+
header,
|
|
3225
|
+
mask,
|
|
3226
|
+
callFrame,
|
|
3227
|
+
};
|
|
3228
|
+
},
|
|
3093
3229
|
};
|
|
3094
3230
|
}
|
|
3095
3231
|
const createGraphQLScopedHandler = (expectedOperationType, mask) => {
|