msw 0.36.8 → 0.38.0
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/lib/esm/fetch-deps.js +11 -11
- package/lib/esm/graphql-deps.js +1980 -1804
- package/lib/esm/index.js +59 -44
- package/lib/esm/mockServiceWorker.js +1 -1
- package/lib/iife/index.js +3 -3
- package/lib/iife/mockServiceWorker.js +1 -1
- package/lib/types/handlers/RequestHandler.d.ts +1 -1
- package/lib/types/response.d.ts +1 -1
- package/lib/types/setupWorker/glossary.d.ts +1 -1
- package/lib/types/utils/logging/prepareResponse.d.ts +1 -1
- package/lib/types/utils/request/onUnhandledRequest.d.ts +5 -1
- package/lib/umd/index.js +18036 -15295
- package/lib/umd/mockServiceWorker.js +1 -1
- package/native/lib/index.js +2022 -1831
- package/node/lib/index.js +2022 -1831
- package/package.json +21 -22
package/native/lib/index.js
CHANGED
|
@@ -183,7 +183,6 @@ var serialize_1 = serialize;
|
|
|
183
183
|
|
|
184
184
|
var decode = decodeURIComponent;
|
|
185
185
|
var encode = encodeURIComponent;
|
|
186
|
-
var pairSplitRegExp = /; */;
|
|
187
186
|
|
|
188
187
|
/**
|
|
189
188
|
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
@@ -214,28 +213,29 @@ function parse$2(str, options) {
|
|
|
214
213
|
|
|
215
214
|
var obj = {};
|
|
216
215
|
var opt = options || {};
|
|
217
|
-
var pairs = str.split(
|
|
216
|
+
var pairs = str.split(';');
|
|
218
217
|
var dec = opt.decode || decode;
|
|
219
218
|
|
|
220
219
|
for (var i = 0; i < pairs.length; i++) {
|
|
221
220
|
var pair = pairs[i];
|
|
222
|
-
var
|
|
221
|
+
var index = pair.indexOf('=');
|
|
223
222
|
|
|
224
223
|
// skip things that don't look like key=value
|
|
225
|
-
if (
|
|
224
|
+
if (index < 0) {
|
|
226
225
|
continue;
|
|
227
226
|
}
|
|
228
227
|
|
|
229
|
-
var key = pair.
|
|
230
|
-
var val = pair.substr(++eq_idx, pair.length).trim();
|
|
231
|
-
|
|
232
|
-
// quoted values
|
|
233
|
-
if ('"' == val[0]) {
|
|
234
|
-
val = val.slice(1, -1);
|
|
235
|
-
}
|
|
228
|
+
var key = pair.substring(0, index).trim();
|
|
236
229
|
|
|
237
230
|
// only assign once
|
|
238
231
|
if (undefined == obj[key]) {
|
|
232
|
+
var val = pair.substring(index + 1, pair.length).trim();
|
|
233
|
+
|
|
234
|
+
// quoted values
|
|
235
|
+
if (val[0] === '"') {
|
|
236
|
+
val = val.slice(1, -1);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
239
|
obj[key] = tryDecode(val, dec);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -1391,20 +1391,33 @@ var jsLevenshtein = (function()
|
|
|
1391
1391
|
};
|
|
1392
1392
|
})();
|
|
1393
1393
|
|
|
1394
|
-
function
|
|
1394
|
+
function devAssert(condition, message) {
|
|
1395
|
+
const booleanCondition = Boolean(condition);
|
|
1396
|
+
|
|
1397
|
+
if (!booleanCondition) {
|
|
1398
|
+
throw new Error(message);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1395
1401
|
|
|
1396
1402
|
/**
|
|
1397
1403
|
* Return true if `value` is object-like. A value is object-like if it's not
|
|
1398
1404
|
* `null` and has a `typeof` result of "object".
|
|
1399
1405
|
*/
|
|
1400
1406
|
function isObjectLike(value) {
|
|
1401
|
-
return
|
|
1407
|
+
return typeof value == 'object' && value !== null;
|
|
1402
1408
|
}
|
|
1403
1409
|
|
|
1404
|
-
|
|
1410
|
+
function invariant(condition, message) {
|
|
1411
|
+
const booleanCondition = Boolean(condition);
|
|
1405
1412
|
|
|
1406
|
-
|
|
1413
|
+
if (!booleanCondition) {
|
|
1414
|
+
throw new Error(
|
|
1415
|
+
message != null ? message : 'Unexpected invariant triggered.',
|
|
1416
|
+
);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1407
1419
|
|
|
1420
|
+
const LineRegExp = /\r\n|[\n\r]/g;
|
|
1408
1421
|
/**
|
|
1409
1422
|
* Represents a location in a Source.
|
|
1410
1423
|
*/
|
|
@@ -1414,115 +1427,107 @@ var SYMBOL_TO_STRING_TAG = typeof Symbol === 'function' && Symbol.toStringTag !=
|
|
|
1414
1427
|
* line and column as a SourceLocation.
|
|
1415
1428
|
*/
|
|
1416
1429
|
function getLocation(source, position) {
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1430
|
+
let lastLineStart = 0;
|
|
1431
|
+
let line = 1;
|
|
1432
|
+
|
|
1433
|
+
for (const match of source.body.matchAll(LineRegExp)) {
|
|
1434
|
+
typeof match.index === 'number' || invariant(false);
|
|
1421
1435
|
|
|
1422
|
-
|
|
1436
|
+
if (match.index >= position) {
|
|
1437
|
+
break;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
lastLineStart = match.index + match[0].length;
|
|
1423
1441
|
line += 1;
|
|
1424
|
-
column = position + 1 - (match.index + match[0].length);
|
|
1425
1442
|
}
|
|
1426
1443
|
|
|
1427
1444
|
return {
|
|
1428
|
-
line
|
|
1429
|
-
column:
|
|
1445
|
+
line,
|
|
1446
|
+
column: position + 1 - lastLineStart,
|
|
1430
1447
|
};
|
|
1431
1448
|
}
|
|
1432
1449
|
|
|
1433
1450
|
/**
|
|
1434
1451
|
* Render a helpful description of the location in the GraphQL Source document.
|
|
1435
1452
|
*/
|
|
1436
|
-
|
|
1437
1453
|
function printLocation(location) {
|
|
1438
|
-
return printSourceLocation(
|
|
1454
|
+
return printSourceLocation(
|
|
1455
|
+
location.source,
|
|
1456
|
+
getLocation(location.source, location.start),
|
|
1457
|
+
);
|
|
1439
1458
|
}
|
|
1440
1459
|
/**
|
|
1441
1460
|
* Render a helpful description of the location in the GraphQL Source document.
|
|
1442
1461
|
*/
|
|
1443
1462
|
|
|
1444
1463
|
function printSourceLocation(source, sourceLocation) {
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1464
|
+
const firstLineColumnOffset = source.locationOffset.column - 1;
|
|
1465
|
+
const body = ''.padStart(firstLineColumnOffset) + source.body;
|
|
1466
|
+
const lineIndex = sourceLocation.line - 1;
|
|
1467
|
+
const lineOffset = source.locationOffset.line - 1;
|
|
1468
|
+
const lineNum = sourceLocation.line + lineOffset;
|
|
1469
|
+
const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;
|
|
1470
|
+
const columnNum = sourceLocation.column + columnOffset;
|
|
1471
|
+
const locationStr = `${source.name}:${lineNum}:${columnNum}\n`;
|
|
1472
|
+
const lines = body.split(/\r\n|[\n\r]/g);
|
|
1473
|
+
const locationLine = lines[lineIndex]; // Special case for minified documents
|
|
1455
1474
|
|
|
1456
1475
|
if (locationLine.length > 120) {
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1476
|
+
const subLineIndex = Math.floor(columnNum / 80);
|
|
1477
|
+
const subLineColumnNum = columnNum % 80;
|
|
1478
|
+
const subLines = [];
|
|
1460
1479
|
|
|
1461
|
-
for (
|
|
1480
|
+
for (let i = 0; i < locationLine.length; i += 80) {
|
|
1462
1481
|
subLines.push(locationLine.slice(i, i + 80));
|
|
1463
1482
|
}
|
|
1464
1483
|
|
|
1465
|
-
return
|
|
1466
|
-
|
|
1467
|
-
|
|
1484
|
+
return (
|
|
1485
|
+
locationStr +
|
|
1486
|
+
printPrefixedLines([
|
|
1487
|
+
[`${lineNum} |`, subLines[0]],
|
|
1488
|
+
...subLines.slice(1, subLineIndex + 1).map((subLine) => ['|', subLine]),
|
|
1489
|
+
['|', '^'.padStart(subLineColumnNum)],
|
|
1490
|
+
['|', subLines[subLineIndex + 1]],
|
|
1491
|
+
])
|
|
1492
|
+
);
|
|
1468
1493
|
}
|
|
1469
1494
|
|
|
1470
|
-
return
|
|
1471
|
-
|
|
1495
|
+
return (
|
|
1496
|
+
locationStr +
|
|
1497
|
+
printPrefixedLines([
|
|
1498
|
+
// Lines specified like this: ["prefix", "string"],
|
|
1499
|
+
[`${lineNum - 1} |`, lines[lineIndex - 1]],
|
|
1500
|
+
[`${lineNum} |`, locationLine],
|
|
1501
|
+
['|', '^'.padStart(columnNum)],
|
|
1502
|
+
[`${lineNum + 1} |`, lines[lineIndex + 1]],
|
|
1503
|
+
])
|
|
1504
|
+
);
|
|
1472
1505
|
}
|
|
1473
1506
|
|
|
1474
1507
|
function printPrefixedLines(lines) {
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
var padLen = Math.max.apply(Math, existingLines.map(function (_ref2) {
|
|
1481
|
-
var prefix = _ref2[0];
|
|
1482
|
-
return prefix.length;
|
|
1483
|
-
}));
|
|
1484
|
-
return existingLines.map(function (_ref3) {
|
|
1485
|
-
var prefix = _ref3[0],
|
|
1486
|
-
line = _ref3[1];
|
|
1487
|
-
return leftPad(padLen, prefix) + (line ? ' | ' + line : ' |');
|
|
1488
|
-
}).join('\n');
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
function whitespace(len) {
|
|
1492
|
-
return Array(len + 1).join(' ');
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
function leftPad(len, str) {
|
|
1496
|
-
return whitespace(len - str.length) + str;
|
|
1508
|
+
const existingLines = lines.filter(([_, line]) => line !== undefined);
|
|
1509
|
+
const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
|
|
1510
|
+
return existingLines
|
|
1511
|
+
.map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : ''))
|
|
1512
|
+
.join('\n');
|
|
1497
1513
|
}
|
|
1498
1514
|
|
|
1499
|
-
function
|
|
1500
|
-
|
|
1501
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1502
|
-
|
|
1503
|
-
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); } }
|
|
1504
|
-
|
|
1505
|
-
function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
|
|
1506
|
-
|
|
1507
|
-
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); }
|
|
1508
|
-
|
|
1509
|
-
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); }; }
|
|
1510
|
-
|
|
1511
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof$2(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
1512
|
-
|
|
1513
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1515
|
+
function toNormalizedArgs(args) {
|
|
1516
|
+
const firstArg = args[0];
|
|
1514
1517
|
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1518
|
+
if (firstArg == null || 'kind' in firstArg || 'length' in firstArg) {
|
|
1519
|
+
return {
|
|
1520
|
+
nodes: firstArg,
|
|
1521
|
+
source: args[1],
|
|
1522
|
+
positions: args[2],
|
|
1523
|
+
path: args[3],
|
|
1524
|
+
originalError: args[4],
|
|
1525
|
+
extensions: args[5],
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1524
1528
|
|
|
1525
|
-
|
|
1529
|
+
return firstArg;
|
|
1530
|
+
}
|
|
1526
1531
|
/**
|
|
1527
1532
|
* A GraphQLError describes an Error found during the parse, validate, or
|
|
1528
1533
|
* execute phases of performing a GraphQL operation. In addition to a message
|
|
@@ -1530,21 +1535,9 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
1530
1535
|
* GraphQL document and/or execution result that correspond to the Error.
|
|
1531
1536
|
*/
|
|
1532
1537
|
|
|
1533
|
-
|
|
1534
|
-
_inherits(GraphQLError, _Error);
|
|
1535
|
-
|
|
1536
|
-
var _super = _createSuper(GraphQLError);
|
|
1537
|
-
|
|
1538
|
-
/**
|
|
1539
|
-
* A message describing the Error for debugging purposes.
|
|
1540
|
-
*
|
|
1541
|
-
* Enumerable, and appears in the result of JSON.stringify().
|
|
1542
|
-
*
|
|
1543
|
-
* Note: should be treated as readonly, despite invariant usage.
|
|
1544
|
-
*/
|
|
1545
|
-
|
|
1538
|
+
class GraphQLError extends Error {
|
|
1546
1539
|
/**
|
|
1547
|
-
* An array of { line, column } locations within the source GraphQL document
|
|
1540
|
+
* An array of `{ line, column }` locations within the source GraphQL document
|
|
1548
1541
|
* which correspond to this error.
|
|
1549
1542
|
*
|
|
1550
1543
|
* Errors during validation often contain multiple locations, for example to
|
|
@@ -1584,184 +1577,163 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
1584
1577
|
/**
|
|
1585
1578
|
* Extension fields to add to the formatted error.
|
|
1586
1579
|
*/
|
|
1587
|
-
function GraphQLError(message, nodes, source, positions, path, originalError, extensions) {
|
|
1588
|
-
var _locations2, _source2, _positions2, _extensions2;
|
|
1589
|
-
|
|
1590
|
-
var _this;
|
|
1591
|
-
|
|
1592
|
-
_classCallCheck(this, GraphQLError);
|
|
1593
|
-
|
|
1594
|
-
_this = _super.call(this, message); // Compute list of blame nodes.
|
|
1595
|
-
|
|
1596
|
-
var _nodes = Array.isArray(nodes) ? nodes.length !== 0 ? nodes : undefined : nodes ? [nodes] : undefined; // Compute locations in the source for the given nodes/positions.
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
var _source = source;
|
|
1600
|
-
|
|
1601
|
-
if (!_source && _nodes) {
|
|
1602
|
-
var _nodes$0$loc;
|
|
1603
|
-
|
|
1604
|
-
_source = (_nodes$0$loc = _nodes[0].loc) === null || _nodes$0$loc === void 0 ? void 0 : _nodes$0$loc.source;
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
var _positions = positions;
|
|
1608
|
-
|
|
1609
|
-
if (!_positions && _nodes) {
|
|
1610
|
-
_positions = _nodes.reduce(function (list, node) {
|
|
1611
|
-
if (node.loc) {
|
|
1612
|
-
list.push(node.loc.start);
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
return list;
|
|
1616
|
-
}, []);
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
if (_positions && _positions.length === 0) {
|
|
1620
|
-
_positions = undefined;
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
var _locations;
|
|
1624
|
-
|
|
1625
|
-
if (positions && source) {
|
|
1626
|
-
_locations = positions.map(function (pos) {
|
|
1627
|
-
return getLocation(source, pos);
|
|
1628
|
-
});
|
|
1629
|
-
} else if (_nodes) {
|
|
1630
|
-
_locations = _nodes.reduce(function (list, node) {
|
|
1631
|
-
if (node.loc) {
|
|
1632
|
-
list.push(getLocation(node.loc.source, node.loc.start));
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
return list;
|
|
1636
|
-
}, []);
|
|
1637
|
-
}
|
|
1638
1580
|
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1581
|
+
/**
|
|
1582
|
+
* @deprecated Please use the `GraphQLErrorArgs` constructor overload instead.
|
|
1583
|
+
*/
|
|
1584
|
+
constructor(message, ...rawArgs) {
|
|
1585
|
+
var _this$nodes, _nodeLocations$, _ref;
|
|
1586
|
+
|
|
1587
|
+
const { nodes, source, positions, path, originalError, extensions } =
|
|
1588
|
+
toNormalizedArgs(rawArgs);
|
|
1589
|
+
super(message);
|
|
1590
|
+
this.name = 'GraphQLError';
|
|
1591
|
+
this.path = path !== null && path !== void 0 ? path : undefined;
|
|
1592
|
+
this.originalError =
|
|
1593
|
+
originalError !== null && originalError !== void 0
|
|
1594
|
+
? originalError
|
|
1595
|
+
: undefined; // Compute list of blame nodes.
|
|
1596
|
+
|
|
1597
|
+
this.nodes = undefinedIfEmpty(
|
|
1598
|
+
Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined,
|
|
1599
|
+
);
|
|
1600
|
+
const nodeLocations = undefinedIfEmpty(
|
|
1601
|
+
(_this$nodes = this.nodes) === null || _this$nodes === void 0
|
|
1602
|
+
? void 0
|
|
1603
|
+
: _this$nodes.map((node) => node.loc).filter((loc) => loc != null),
|
|
1604
|
+
); // Compute locations in the source for the given nodes/positions.
|
|
1605
|
+
|
|
1606
|
+
this.source =
|
|
1607
|
+
source !== null && source !== void 0
|
|
1608
|
+
? source
|
|
1609
|
+
: nodeLocations === null || nodeLocations === void 0
|
|
1610
|
+
? void 0
|
|
1611
|
+
: (_nodeLocations$ = nodeLocations[0]) === null ||
|
|
1612
|
+
_nodeLocations$ === void 0
|
|
1613
|
+
? void 0
|
|
1614
|
+
: _nodeLocations$.source;
|
|
1615
|
+
this.positions =
|
|
1616
|
+
positions !== null && positions !== void 0
|
|
1617
|
+
? positions
|
|
1618
|
+
: nodeLocations === null || nodeLocations === void 0
|
|
1619
|
+
? void 0
|
|
1620
|
+
: nodeLocations.map((loc) => loc.start);
|
|
1621
|
+
this.locations =
|
|
1622
|
+
positions && source
|
|
1623
|
+
? positions.map((pos) => getLocation(source, pos))
|
|
1624
|
+
: nodeLocations === null || nodeLocations === void 0
|
|
1625
|
+
? void 0
|
|
1626
|
+
: nodeLocations.map((loc) => getLocation(loc.source, loc.start));
|
|
1627
|
+
const originalExtensions = isObjectLike(
|
|
1628
|
+
originalError === null || originalError === void 0
|
|
1629
|
+
? void 0
|
|
1630
|
+
: originalError.extensions,
|
|
1631
|
+
)
|
|
1632
|
+
? originalError === null || originalError === void 0
|
|
1633
|
+
? void 0
|
|
1634
|
+
: originalError.extensions
|
|
1635
|
+
: undefined;
|
|
1636
|
+
this.extensions =
|
|
1637
|
+
(_ref =
|
|
1638
|
+
extensions !== null && extensions !== void 0
|
|
1639
|
+
? extensions
|
|
1640
|
+
: originalExtensions) !== null && _ref !== void 0
|
|
1641
|
+
? _ref
|
|
1642
|
+
: Object.create(null); // Only properties prescribed by the spec should be enumerable.
|
|
1643
|
+
// Keep the rest as non-enumerable.
|
|
1644
|
+
|
|
1645
|
+
Object.defineProperties(this, {
|
|
1653
1646
|
message: {
|
|
1654
|
-
|
|
1655
|
-
// By being enumerable, JSON.stringify will include `message` in the
|
|
1656
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
1657
|
-
// service adheres to the spec.
|
|
1647
|
+
writable: true,
|
|
1658
1648
|
enumerable: true,
|
|
1659
|
-
writable: true
|
|
1660
1649
|
},
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
// in JSON.stringify() when not provided.
|
|
1664
|
-
value: (_locations2 = _locations) !== null && _locations2 !== void 0 ? _locations2 : undefined,
|
|
1665
|
-
// By being enumerable, JSON.stringify will include `locations` in the
|
|
1666
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
1667
|
-
// service adheres to the spec.
|
|
1668
|
-
enumerable: _locations != null
|
|
1669
|
-
},
|
|
1670
|
-
path: {
|
|
1671
|
-
// Coercing falsy values to undefined ensures they will not be included
|
|
1672
|
-
// in JSON.stringify() when not provided.
|
|
1673
|
-
value: path !== null && path !== void 0 ? path : undefined,
|
|
1674
|
-
// By being enumerable, JSON.stringify will include `path` in the
|
|
1675
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
1676
|
-
// service adheres to the spec.
|
|
1677
|
-
enumerable: path != null
|
|
1650
|
+
name: {
|
|
1651
|
+
enumerable: false,
|
|
1678
1652
|
},
|
|
1679
1653
|
nodes: {
|
|
1680
|
-
|
|
1654
|
+
enumerable: false,
|
|
1681
1655
|
},
|
|
1682
1656
|
source: {
|
|
1683
|
-
|
|
1657
|
+
enumerable: false,
|
|
1684
1658
|
},
|
|
1685
1659
|
positions: {
|
|
1686
|
-
|
|
1660
|
+
enumerable: false,
|
|
1687
1661
|
},
|
|
1688
1662
|
originalError: {
|
|
1689
|
-
|
|
1663
|
+
enumerable: false,
|
|
1690
1664
|
},
|
|
1691
|
-
extensions: {
|
|
1692
|
-
// Coercing falsy values to undefined ensures they will not be included
|
|
1693
|
-
// in JSON.stringify() when not provided.
|
|
1694
|
-
value: (_extensions2 = _extensions) !== null && _extensions2 !== void 0 ? _extensions2 : undefined,
|
|
1695
|
-
// By being enumerable, JSON.stringify will include `path` in the
|
|
1696
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
1697
|
-
// service adheres to the spec.
|
|
1698
|
-
enumerable: _extensions != null
|
|
1699
|
-
}
|
|
1700
1665
|
}); // Include (non-enumerable) stack trace.
|
|
1701
1666
|
|
|
1702
|
-
|
|
1703
|
-
|
|
1667
|
+
/* c8 ignore start */
|
|
1668
|
+
// FIXME: https://github.com/graphql/graphql-js/issues/2317
|
|
1669
|
+
|
|
1670
|
+
if (
|
|
1671
|
+
originalError !== null &&
|
|
1672
|
+
originalError !== void 0 &&
|
|
1673
|
+
originalError.stack
|
|
1674
|
+
) {
|
|
1675
|
+
Object.defineProperty(this, 'stack', {
|
|
1704
1676
|
value: originalError.stack,
|
|
1705
1677
|
writable: true,
|
|
1706
|
-
configurable: true
|
|
1678
|
+
configurable: true,
|
|
1707
1679
|
});
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
if (Error.captureStackTrace) {
|
|
1713
|
-
Error.captureStackTrace(_assertThisInitialized(_this), GraphQLError);
|
|
1680
|
+
} else if (Error.captureStackTrace) {
|
|
1681
|
+
Error.captureStackTrace(this, GraphQLError);
|
|
1714
1682
|
} else {
|
|
1715
|
-
Object.defineProperty(
|
|
1683
|
+
Object.defineProperty(this, 'stack', {
|
|
1716
1684
|
value: Error().stack,
|
|
1717
1685
|
writable: true,
|
|
1718
|
-
configurable: true
|
|
1686
|
+
configurable: true,
|
|
1719
1687
|
});
|
|
1720
1688
|
}
|
|
1689
|
+
/* c8 ignore stop */
|
|
1690
|
+
}
|
|
1721
1691
|
|
|
1722
|
-
|
|
1692
|
+
get [Symbol.toStringTag]() {
|
|
1693
|
+
return 'GraphQLError';
|
|
1723
1694
|
}
|
|
1724
1695
|
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1696
|
+
toString() {
|
|
1697
|
+
let output = this.message;
|
|
1698
|
+
|
|
1699
|
+
if (this.nodes) {
|
|
1700
|
+
for (const node of this.nodes) {
|
|
1701
|
+
if (node.loc) {
|
|
1702
|
+
output += '\n\n' + printLocation(node.loc);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
} else if (this.source && this.locations) {
|
|
1706
|
+
for (const location of this.locations) {
|
|
1707
|
+
output += '\n\n' + printSourceLocation(this.source, location);
|
|
1708
|
+
}
|
|
1736
1709
|
}
|
|
1737
|
-
}]);
|
|
1738
1710
|
|
|
1739
|
-
|
|
1740
|
-
}
|
|
1741
|
-
/**
|
|
1742
|
-
* Prints a GraphQLError to a string, representing useful location information
|
|
1743
|
-
* about the error's position in the source.
|
|
1744
|
-
*/
|
|
1711
|
+
return output;
|
|
1712
|
+
}
|
|
1745
1713
|
|
|
1746
|
-
|
|
1747
|
-
|
|
1714
|
+
toJSON() {
|
|
1715
|
+
const formattedError = {
|
|
1716
|
+
message: this.message,
|
|
1717
|
+
};
|
|
1748
1718
|
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1719
|
+
if (this.locations != null) {
|
|
1720
|
+
formattedError.locations = this.locations;
|
|
1721
|
+
}
|
|
1752
1722
|
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
}
|
|
1723
|
+
if (this.path != null) {
|
|
1724
|
+
formattedError.path = this.path;
|
|
1756
1725
|
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
output += '\n\n' + printSourceLocation(error.source, location);
|
|
1726
|
+
|
|
1727
|
+
if (this.extensions != null && Object.keys(this.extensions).length > 0) {
|
|
1728
|
+
formattedError.extensions = this.extensions;
|
|
1761
1729
|
}
|
|
1730
|
+
|
|
1731
|
+
return formattedError;
|
|
1762
1732
|
}
|
|
1733
|
+
}
|
|
1763
1734
|
|
|
1764
|
-
|
|
1735
|
+
function undefinedIfEmpty(array) {
|
|
1736
|
+
return array === undefined || array.length === 0 ? undefined : array;
|
|
1765
1737
|
}
|
|
1766
1738
|
|
|
1767
1739
|
/**
|
|
@@ -1770,103 +1742,16 @@ function printError(error) {
|
|
|
1770
1742
|
*/
|
|
1771
1743
|
|
|
1772
1744
|
function syntaxError(source, position, description) {
|
|
1773
|
-
return new GraphQLError(
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
/**
|
|
1777
|
-
* The set of allowed kind values for AST nodes.
|
|
1778
|
-
*/
|
|
1779
|
-
var Kind = Object.freeze({
|
|
1780
|
-
// Name
|
|
1781
|
-
NAME: 'Name',
|
|
1782
|
-
// Document
|
|
1783
|
-
DOCUMENT: 'Document',
|
|
1784
|
-
OPERATION_DEFINITION: 'OperationDefinition',
|
|
1785
|
-
VARIABLE_DEFINITION: 'VariableDefinition',
|
|
1786
|
-
SELECTION_SET: 'SelectionSet',
|
|
1787
|
-
FIELD: 'Field',
|
|
1788
|
-
ARGUMENT: 'Argument',
|
|
1789
|
-
// Fragments
|
|
1790
|
-
FRAGMENT_SPREAD: 'FragmentSpread',
|
|
1791
|
-
INLINE_FRAGMENT: 'InlineFragment',
|
|
1792
|
-
FRAGMENT_DEFINITION: 'FragmentDefinition',
|
|
1793
|
-
// Values
|
|
1794
|
-
VARIABLE: 'Variable',
|
|
1795
|
-
INT: 'IntValue',
|
|
1796
|
-
FLOAT: 'FloatValue',
|
|
1797
|
-
STRING: 'StringValue',
|
|
1798
|
-
BOOLEAN: 'BooleanValue',
|
|
1799
|
-
NULL: 'NullValue',
|
|
1800
|
-
ENUM: 'EnumValue',
|
|
1801
|
-
LIST: 'ListValue',
|
|
1802
|
-
OBJECT: 'ObjectValue',
|
|
1803
|
-
OBJECT_FIELD: 'ObjectField',
|
|
1804
|
-
// Directives
|
|
1805
|
-
DIRECTIVE: 'Directive',
|
|
1806
|
-
// Types
|
|
1807
|
-
NAMED_TYPE: 'NamedType',
|
|
1808
|
-
LIST_TYPE: 'ListType',
|
|
1809
|
-
NON_NULL_TYPE: 'NonNullType',
|
|
1810
|
-
// Type System Definitions
|
|
1811
|
-
SCHEMA_DEFINITION: 'SchemaDefinition',
|
|
1812
|
-
OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition',
|
|
1813
|
-
// Type Definitions
|
|
1814
|
-
SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition',
|
|
1815
|
-
OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition',
|
|
1816
|
-
FIELD_DEFINITION: 'FieldDefinition',
|
|
1817
|
-
INPUT_VALUE_DEFINITION: 'InputValueDefinition',
|
|
1818
|
-
INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition',
|
|
1819
|
-
UNION_TYPE_DEFINITION: 'UnionTypeDefinition',
|
|
1820
|
-
ENUM_TYPE_DEFINITION: 'EnumTypeDefinition',
|
|
1821
|
-
ENUM_VALUE_DEFINITION: 'EnumValueDefinition',
|
|
1822
|
-
INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition',
|
|
1823
|
-
// Directive Definitions
|
|
1824
|
-
DIRECTIVE_DEFINITION: 'DirectiveDefinition',
|
|
1825
|
-
// Type System Extensions
|
|
1826
|
-
SCHEMA_EXTENSION: 'SchemaExtension',
|
|
1827
|
-
// Type Extensions
|
|
1828
|
-
SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension',
|
|
1829
|
-
OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension',
|
|
1830
|
-
INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension',
|
|
1831
|
-
UNION_TYPE_EXTENSION: 'UnionTypeExtension',
|
|
1832
|
-
ENUM_TYPE_EXTENSION: 'EnumTypeExtension',
|
|
1833
|
-
INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension'
|
|
1834
|
-
});
|
|
1835
|
-
/**
|
|
1836
|
-
* The enum type representing the possible kind values of AST nodes.
|
|
1837
|
-
*/
|
|
1838
|
-
|
|
1839
|
-
function invariant(condition, message) {
|
|
1840
|
-
var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
|
|
1841
|
-
|
|
1842
|
-
if (!booleanCondition) {
|
|
1843
|
-
throw new Error(message != null ? message : 'Unexpected invariant triggered.');
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
1848
|
-
var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
|
|
1849
|
-
var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
|
|
1850
|
-
|
|
1851
|
-
/**
|
|
1852
|
-
* The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
|
|
1853
|
-
*/
|
|
1854
|
-
|
|
1855
|
-
function defineInspect(classObject) {
|
|
1856
|
-
var fn = classObject.prototype.toJSON;
|
|
1857
|
-
typeof fn === 'function' || invariant(0);
|
|
1858
|
-
classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
1859
|
-
|
|
1860
|
-
if (nodejsCustomInspectSymbol$1) {
|
|
1861
|
-
classObject.prototype[nodejsCustomInspectSymbol$1] = fn;
|
|
1862
|
-
}
|
|
1745
|
+
return new GraphQLError(`Syntax Error: ${description}`, undefined, source, [
|
|
1746
|
+
position,
|
|
1747
|
+
]);
|
|
1863
1748
|
}
|
|
1864
1749
|
|
|
1865
1750
|
/**
|
|
1866
1751
|
* Contains a range of UTF-8 character offsets and token references that
|
|
1867
1752
|
* identify the region of the source from which the AST derived.
|
|
1868
1753
|
*/
|
|
1869
|
-
|
|
1754
|
+
class Location {
|
|
1870
1755
|
/**
|
|
1871
1756
|
* The character offset at which this Node begins.
|
|
1872
1757
|
*/
|
|
@@ -1886,7 +1771,7 @@ var Location = /*#__PURE__*/function () {
|
|
|
1886
1771
|
/**
|
|
1887
1772
|
* The Source document the AST represents.
|
|
1888
1773
|
*/
|
|
1889
|
-
|
|
1774
|
+
constructor(startToken, endToken, source) {
|
|
1890
1775
|
this.start = startToken.start;
|
|
1891
1776
|
this.end = endToken.end;
|
|
1892
1777
|
this.startToken = startToken;
|
|
@@ -1894,25 +1779,23 @@ var Location = /*#__PURE__*/function () {
|
|
|
1894
1779
|
this.source = source;
|
|
1895
1780
|
}
|
|
1896
1781
|
|
|
1897
|
-
|
|
1782
|
+
get [Symbol.toStringTag]() {
|
|
1783
|
+
return 'Location';
|
|
1784
|
+
}
|
|
1898
1785
|
|
|
1899
|
-
|
|
1786
|
+
toJSON() {
|
|
1900
1787
|
return {
|
|
1901
1788
|
start: this.start,
|
|
1902
|
-
end: this.end
|
|
1789
|
+
end: this.end,
|
|
1903
1790
|
};
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
return Location;
|
|
1907
|
-
}(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
|
|
1908
|
-
|
|
1909
|
-
defineInspect(Location);
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1910
1793
|
/**
|
|
1911
1794
|
* Represents a range of characters represented by a lexical token
|
|
1912
1795
|
* within a Source.
|
|
1913
1796
|
*/
|
|
1914
1797
|
|
|
1915
|
-
|
|
1798
|
+
class Token {
|
|
1916
1799
|
/**
|
|
1917
1800
|
* The kind of Token.
|
|
1918
1801
|
*/
|
|
@@ -1935,6 +1818,9 @@ var Token = /*#__PURE__*/function () {
|
|
|
1935
1818
|
|
|
1936
1819
|
/**
|
|
1937
1820
|
* For non-punctuation tokens, represents the interpreted value of the token.
|
|
1821
|
+
*
|
|
1822
|
+
* Note: is undefined for punctuation tokens, but typed as string for
|
|
1823
|
+
* convenience in the parser.
|
|
1938
1824
|
*/
|
|
1939
1825
|
|
|
1940
1826
|
/**
|
|
@@ -1942,403 +1828,288 @@ var Token = /*#__PURE__*/function () {
|
|
|
1942
1828
|
* including ignored tokens. <SOF> is always the first node and <EOF>
|
|
1943
1829
|
* the last.
|
|
1944
1830
|
*/
|
|
1945
|
-
|
|
1831
|
+
constructor(kind, start, end, line, column, value) {
|
|
1946
1832
|
this.kind = kind;
|
|
1947
1833
|
this.start = start;
|
|
1948
1834
|
this.end = end;
|
|
1949
1835
|
this.line = line;
|
|
1950
|
-
this.column = column;
|
|
1836
|
+
this.column = column; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1837
|
+
|
|
1951
1838
|
this.value = value;
|
|
1952
|
-
this.prev =
|
|
1839
|
+
this.prev = null;
|
|
1953
1840
|
this.next = null;
|
|
1954
1841
|
}
|
|
1955
1842
|
|
|
1956
|
-
|
|
1843
|
+
get [Symbol.toStringTag]() {
|
|
1844
|
+
return 'Token';
|
|
1845
|
+
}
|
|
1957
1846
|
|
|
1958
|
-
|
|
1847
|
+
toJSON() {
|
|
1959
1848
|
return {
|
|
1960
1849
|
kind: this.kind,
|
|
1961
1850
|
value: this.value,
|
|
1962
1851
|
line: this.line,
|
|
1963
|
-
column: this.column
|
|
1852
|
+
column: this.column,
|
|
1964
1853
|
};
|
|
1965
|
-
}
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
/** Name */
|
|
1857
|
+
|
|
1858
|
+
let OperationTypeNode;
|
|
1966
1859
|
|
|
1967
|
-
|
|
1968
|
-
|
|
1860
|
+
(function (OperationTypeNode) {
|
|
1861
|
+
OperationTypeNode['QUERY'] = 'query';
|
|
1862
|
+
OperationTypeNode['MUTATION'] = 'mutation';
|
|
1863
|
+
OperationTypeNode['SUBSCRIPTION'] = 'subscription';
|
|
1864
|
+
})(OperationTypeNode || (OperationTypeNode = {}));
|
|
1969
1865
|
|
|
1970
|
-
defineInspect(Token);
|
|
1971
1866
|
/**
|
|
1972
|
-
* The
|
|
1867
|
+
* The set of allowed directive location values.
|
|
1868
|
+
*/
|
|
1869
|
+
let DirectiveLocation;
|
|
1870
|
+
/**
|
|
1871
|
+
* The enum type representing the directive location values.
|
|
1872
|
+
*
|
|
1873
|
+
* @deprecated Please use `DirectiveLocation`. Will be remove in v17.
|
|
1973
1874
|
*/
|
|
1974
1875
|
|
|
1876
|
+
(function (DirectiveLocation) {
|
|
1877
|
+
DirectiveLocation['QUERY'] = 'QUERY';
|
|
1878
|
+
DirectiveLocation['MUTATION'] = 'MUTATION';
|
|
1879
|
+
DirectiveLocation['SUBSCRIPTION'] = 'SUBSCRIPTION';
|
|
1880
|
+
DirectiveLocation['FIELD'] = 'FIELD';
|
|
1881
|
+
DirectiveLocation['FRAGMENT_DEFINITION'] = 'FRAGMENT_DEFINITION';
|
|
1882
|
+
DirectiveLocation['FRAGMENT_SPREAD'] = 'FRAGMENT_SPREAD';
|
|
1883
|
+
DirectiveLocation['INLINE_FRAGMENT'] = 'INLINE_FRAGMENT';
|
|
1884
|
+
DirectiveLocation['VARIABLE_DEFINITION'] = 'VARIABLE_DEFINITION';
|
|
1885
|
+
DirectiveLocation['SCHEMA'] = 'SCHEMA';
|
|
1886
|
+
DirectiveLocation['SCALAR'] = 'SCALAR';
|
|
1887
|
+
DirectiveLocation['OBJECT'] = 'OBJECT';
|
|
1888
|
+
DirectiveLocation['FIELD_DEFINITION'] = 'FIELD_DEFINITION';
|
|
1889
|
+
DirectiveLocation['ARGUMENT_DEFINITION'] = 'ARGUMENT_DEFINITION';
|
|
1890
|
+
DirectiveLocation['INTERFACE'] = 'INTERFACE';
|
|
1891
|
+
DirectiveLocation['UNION'] = 'UNION';
|
|
1892
|
+
DirectiveLocation['ENUM'] = 'ENUM';
|
|
1893
|
+
DirectiveLocation['ENUM_VALUE'] = 'ENUM_VALUE';
|
|
1894
|
+
DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT';
|
|
1895
|
+
DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION';
|
|
1896
|
+
})(DirectiveLocation || (DirectiveLocation = {}));
|
|
1897
|
+
|
|
1975
1898
|
/**
|
|
1976
|
-
*
|
|
1977
|
-
* lexer emits.
|
|
1899
|
+
* The set of allowed kind values for AST nodes.
|
|
1978
1900
|
*/
|
|
1979
|
-
|
|
1980
|
-
SOF: '<SOF>',
|
|
1981
|
-
EOF: '<EOF>',
|
|
1982
|
-
BANG: '!',
|
|
1983
|
-
DOLLAR: '$',
|
|
1984
|
-
AMP: '&',
|
|
1985
|
-
PAREN_L: '(',
|
|
1986
|
-
PAREN_R: ')',
|
|
1987
|
-
SPREAD: '...',
|
|
1988
|
-
COLON: ':',
|
|
1989
|
-
EQUALS: '=',
|
|
1990
|
-
AT: '@',
|
|
1991
|
-
BRACKET_L: '[',
|
|
1992
|
-
BRACKET_R: ']',
|
|
1993
|
-
BRACE_L: '{',
|
|
1994
|
-
PIPE: '|',
|
|
1995
|
-
BRACE_R: '}',
|
|
1996
|
-
NAME: 'Name',
|
|
1997
|
-
INT: 'Int',
|
|
1998
|
-
FLOAT: 'Float',
|
|
1999
|
-
STRING: 'String',
|
|
2000
|
-
BLOCK_STRING: 'BlockString',
|
|
2001
|
-
COMMENT: 'Comment'
|
|
2002
|
-
});
|
|
1901
|
+
let Kind;
|
|
2003
1902
|
/**
|
|
2004
|
-
* The enum type representing the
|
|
1903
|
+
* The enum type representing the possible kind values of AST nodes.
|
|
1904
|
+
*
|
|
1905
|
+
* @deprecated Please use `Kind`. Will be remove in v17.
|
|
2005
1906
|
*/
|
|
2006
1907
|
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
1908
|
+
(function (Kind) {
|
|
1909
|
+
Kind['NAME'] = 'Name';
|
|
1910
|
+
Kind['DOCUMENT'] = 'Document';
|
|
1911
|
+
Kind['OPERATION_DEFINITION'] = 'OperationDefinition';
|
|
1912
|
+
Kind['VARIABLE_DEFINITION'] = 'VariableDefinition';
|
|
1913
|
+
Kind['SELECTION_SET'] = 'SelectionSet';
|
|
1914
|
+
Kind['FIELD'] = 'Field';
|
|
1915
|
+
Kind['ARGUMENT'] = 'Argument';
|
|
1916
|
+
Kind['FRAGMENT_SPREAD'] = 'FragmentSpread';
|
|
1917
|
+
Kind['INLINE_FRAGMENT'] = 'InlineFragment';
|
|
1918
|
+
Kind['FRAGMENT_DEFINITION'] = 'FragmentDefinition';
|
|
1919
|
+
Kind['VARIABLE'] = 'Variable';
|
|
1920
|
+
Kind['INT'] = 'IntValue';
|
|
1921
|
+
Kind['FLOAT'] = 'FloatValue';
|
|
1922
|
+
Kind['STRING'] = 'StringValue';
|
|
1923
|
+
Kind['BOOLEAN'] = 'BooleanValue';
|
|
1924
|
+
Kind['NULL'] = 'NullValue';
|
|
1925
|
+
Kind['ENUM'] = 'EnumValue';
|
|
1926
|
+
Kind['LIST'] = 'ListValue';
|
|
1927
|
+
Kind['OBJECT'] = 'ObjectValue';
|
|
1928
|
+
Kind['OBJECT_FIELD'] = 'ObjectField';
|
|
1929
|
+
Kind['DIRECTIVE'] = 'Directive';
|
|
1930
|
+
Kind['NAMED_TYPE'] = 'NamedType';
|
|
1931
|
+
Kind['LIST_TYPE'] = 'ListType';
|
|
1932
|
+
Kind['NON_NULL_TYPE'] = 'NonNullType';
|
|
1933
|
+
Kind['SCHEMA_DEFINITION'] = 'SchemaDefinition';
|
|
1934
|
+
Kind['OPERATION_TYPE_DEFINITION'] = 'OperationTypeDefinition';
|
|
1935
|
+
Kind['SCALAR_TYPE_DEFINITION'] = 'ScalarTypeDefinition';
|
|
1936
|
+
Kind['OBJECT_TYPE_DEFINITION'] = 'ObjectTypeDefinition';
|
|
1937
|
+
Kind['FIELD_DEFINITION'] = 'FieldDefinition';
|
|
1938
|
+
Kind['INPUT_VALUE_DEFINITION'] = 'InputValueDefinition';
|
|
1939
|
+
Kind['INTERFACE_TYPE_DEFINITION'] = 'InterfaceTypeDefinition';
|
|
1940
|
+
Kind['UNION_TYPE_DEFINITION'] = 'UnionTypeDefinition';
|
|
1941
|
+
Kind['ENUM_TYPE_DEFINITION'] = 'EnumTypeDefinition';
|
|
1942
|
+
Kind['ENUM_VALUE_DEFINITION'] = 'EnumValueDefinition';
|
|
1943
|
+
Kind['INPUT_OBJECT_TYPE_DEFINITION'] = 'InputObjectTypeDefinition';
|
|
1944
|
+
Kind['DIRECTIVE_DEFINITION'] = 'DirectiveDefinition';
|
|
1945
|
+
Kind['SCHEMA_EXTENSION'] = 'SchemaExtension';
|
|
1946
|
+
Kind['SCALAR_TYPE_EXTENSION'] = 'ScalarTypeExtension';
|
|
1947
|
+
Kind['OBJECT_TYPE_EXTENSION'] = 'ObjectTypeExtension';
|
|
1948
|
+
Kind['INTERFACE_TYPE_EXTENSION'] = 'InterfaceTypeExtension';
|
|
1949
|
+
Kind['UNION_TYPE_EXTENSION'] = 'UnionTypeExtension';
|
|
1950
|
+
Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension';
|
|
1951
|
+
Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension';
|
|
1952
|
+
})(Kind || (Kind = {}));
|
|
1953
|
+
|
|
2010
1954
|
/**
|
|
2011
|
-
*
|
|
1955
|
+
* ```
|
|
1956
|
+
* WhiteSpace ::
|
|
1957
|
+
* - "Horizontal Tab (U+0009)"
|
|
1958
|
+
* - "Space (U+0020)"
|
|
1959
|
+
* ```
|
|
1960
|
+
* @internal
|
|
2012
1961
|
*/
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
return formatValue(value, []);
|
|
1962
|
+
function isWhiteSpace(code) {
|
|
1963
|
+
return code === 0x0009 || code === 0x0020;
|
|
2016
1964
|
}
|
|
1965
|
+
/**
|
|
1966
|
+
* ```
|
|
1967
|
+
* Digit :: one of
|
|
1968
|
+
* - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
|
|
1969
|
+
* ```
|
|
1970
|
+
* @internal
|
|
1971
|
+
*/
|
|
2017
1972
|
|
|
2018
|
-
function
|
|
2019
|
-
|
|
2020
|
-
case 'string':
|
|
2021
|
-
return JSON.stringify(value);
|
|
2022
|
-
|
|
2023
|
-
case 'function':
|
|
2024
|
-
return value.name ? "[function ".concat(value.name, "]") : '[function]';
|
|
2025
|
-
|
|
2026
|
-
case 'object':
|
|
2027
|
-
if (value === null) {
|
|
2028
|
-
return 'null';
|
|
2029
|
-
}
|
|
2030
|
-
|
|
2031
|
-
return formatObjectValue(value, seenValues);
|
|
2032
|
-
|
|
2033
|
-
default:
|
|
2034
|
-
return String(value);
|
|
2035
|
-
}
|
|
1973
|
+
function isDigit(code) {
|
|
1974
|
+
return code >= 0x0030 && code <= 0x0039;
|
|
2036
1975
|
}
|
|
1976
|
+
/**
|
|
1977
|
+
* ```
|
|
1978
|
+
* Letter :: one of
|
|
1979
|
+
* - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M`
|
|
1980
|
+
* - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z`
|
|
1981
|
+
* - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m`
|
|
1982
|
+
* - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z`
|
|
1983
|
+
* ```
|
|
1984
|
+
* @internal
|
|
1985
|
+
*/
|
|
2037
1986
|
|
|
2038
|
-
function
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
var seenValues = [].concat(previouslySeenValues, [value]);
|
|
2044
|
-
var customInspectFn = getCustomFn(value);
|
|
2045
|
-
|
|
2046
|
-
if (customInspectFn !== undefined) {
|
|
2047
|
-
var customValue = customInspectFn.call(value); // check for infinite recursion
|
|
2048
|
-
|
|
2049
|
-
if (customValue !== value) {
|
|
2050
|
-
return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
|
|
2051
|
-
}
|
|
2052
|
-
} else if (Array.isArray(value)) {
|
|
2053
|
-
return formatArray(value, seenValues);
|
|
2054
|
-
}
|
|
2055
|
-
|
|
2056
|
-
return formatObject(value, seenValues);
|
|
1987
|
+
function isLetter(code) {
|
|
1988
|
+
return (
|
|
1989
|
+
(code >= 0x0061 && code <= 0x007a) || // A-Z
|
|
1990
|
+
(code >= 0x0041 && code <= 0x005a) // a-z
|
|
1991
|
+
);
|
|
2057
1992
|
}
|
|
1993
|
+
/**
|
|
1994
|
+
* ```
|
|
1995
|
+
* NameStart ::
|
|
1996
|
+
* - Letter
|
|
1997
|
+
* - `_`
|
|
1998
|
+
* ```
|
|
1999
|
+
* @internal
|
|
2000
|
+
*/
|
|
2058
2001
|
|
|
2059
|
-
function
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
if (keys.length === 0) {
|
|
2063
|
-
return '{}';
|
|
2064
|
-
}
|
|
2065
|
-
|
|
2066
|
-
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
2067
|
-
return '[' + getObjectTag(object) + ']';
|
|
2068
|
-
}
|
|
2069
|
-
|
|
2070
|
-
var properties = keys.map(function (key) {
|
|
2071
|
-
var value = formatValue(object[key], seenValues);
|
|
2072
|
-
return key + ': ' + value;
|
|
2073
|
-
});
|
|
2074
|
-
return '{ ' + properties.join(', ') + ' }';
|
|
2002
|
+
function isNameStart(code) {
|
|
2003
|
+
return isLetter(code) || code === 0x005f;
|
|
2075
2004
|
}
|
|
2005
|
+
/**
|
|
2006
|
+
* ```
|
|
2007
|
+
* NameContinue ::
|
|
2008
|
+
* - Letter
|
|
2009
|
+
* - Digit
|
|
2010
|
+
* - `_`
|
|
2011
|
+
* ```
|
|
2012
|
+
* @internal
|
|
2013
|
+
*/
|
|
2076
2014
|
|
|
2077
|
-
function
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
|
-
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
2083
|
-
return '[Array]';
|
|
2084
|
-
}
|
|
2085
|
-
|
|
2086
|
-
var len = Math.min(MAX_ARRAY_LENGTH, array.length);
|
|
2087
|
-
var remaining = array.length - len;
|
|
2088
|
-
var items = [];
|
|
2089
|
-
|
|
2090
|
-
for (var i = 0; i < len; ++i) {
|
|
2091
|
-
items.push(formatValue(array[i], seenValues));
|
|
2092
|
-
}
|
|
2015
|
+
function isNameContinue(code) {
|
|
2016
|
+
return isLetter(code) || isDigit(code) || code === 0x005f;
|
|
2017
|
+
}
|
|
2093
2018
|
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2019
|
+
/**
|
|
2020
|
+
* Produces the value of a block string from its parsed raw value, similar to
|
|
2021
|
+
* CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
|
|
2022
|
+
*
|
|
2023
|
+
* This implements the GraphQL spec's BlockStringValue() static algorithm.
|
|
2024
|
+
*
|
|
2025
|
+
* @internal
|
|
2026
|
+
*/
|
|
2099
2027
|
|
|
2100
|
-
|
|
2101
|
-
|
|
2028
|
+
function dedentBlockStringLines(lines) {
|
|
2029
|
+
var _firstNonEmptyLine2;
|
|
2102
2030
|
|
|
2103
|
-
|
|
2104
|
-
|
|
2031
|
+
let commonIndent = Number.MAX_SAFE_INTEGER;
|
|
2032
|
+
let firstNonEmptyLine = null;
|
|
2033
|
+
let lastNonEmptyLine = -1;
|
|
2105
2034
|
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
}
|
|
2035
|
+
for (let i = 0; i < lines.length; ++i) {
|
|
2036
|
+
var _firstNonEmptyLine;
|
|
2109
2037
|
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2038
|
+
const line = lines[i];
|
|
2039
|
+
const indent = leadingWhitespace(line);
|
|
2114
2040
|
|
|
2115
|
-
|
|
2116
|
-
|
|
2041
|
+
if (indent === line.length) {
|
|
2042
|
+
continue; // skip empty lines
|
|
2043
|
+
}
|
|
2117
2044
|
|
|
2118
|
-
|
|
2119
|
-
|
|
2045
|
+
firstNonEmptyLine =
|
|
2046
|
+
(_firstNonEmptyLine = firstNonEmptyLine) !== null &&
|
|
2047
|
+
_firstNonEmptyLine !== void 0
|
|
2048
|
+
? _firstNonEmptyLine
|
|
2049
|
+
: i;
|
|
2050
|
+
lastNonEmptyLine = i;
|
|
2120
2051
|
|
|
2121
|
-
if (
|
|
2122
|
-
|
|
2052
|
+
if (i !== 0 && indent < commonIndent) {
|
|
2053
|
+
commonIndent = indent;
|
|
2123
2054
|
}
|
|
2124
2055
|
}
|
|
2125
2056
|
|
|
2126
|
-
return
|
|
2057
|
+
return lines // Remove common indentation from all lines but first.
|
|
2058
|
+
.map((line, i) => (i === 0 ? line : line.slice(commonIndent))) // Remove leading and trailing blank lines.
|
|
2059
|
+
.slice(
|
|
2060
|
+
(_firstNonEmptyLine2 = firstNonEmptyLine) !== null &&
|
|
2061
|
+
_firstNonEmptyLine2 !== void 0
|
|
2062
|
+
? _firstNonEmptyLine2
|
|
2063
|
+
: 0,
|
|
2064
|
+
lastNonEmptyLine + 1,
|
|
2065
|
+
);
|
|
2127
2066
|
}
|
|
2128
2067
|
|
|
2129
|
-
function
|
|
2130
|
-
|
|
2068
|
+
function leadingWhitespace(str) {
|
|
2069
|
+
let i = 0;
|
|
2131
2070
|
|
|
2132
|
-
|
|
2133
|
-
|
|
2071
|
+
while (i < str.length && isWhiteSpace(str.charCodeAt(i))) {
|
|
2072
|
+
++i;
|
|
2134
2073
|
}
|
|
2074
|
+
|
|
2075
|
+
return i;
|
|
2135
2076
|
}
|
|
2136
2077
|
|
|
2137
|
-
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); }
|
|
2138
2078
|
/**
|
|
2139
|
-
*
|
|
2140
|
-
*
|
|
2079
|
+
* An exported enum describing the different kinds of tokens that the
|
|
2080
|
+
* lexer emits.
|
|
2081
|
+
*/
|
|
2082
|
+
let TokenKind;
|
|
2083
|
+
/**
|
|
2084
|
+
* The enum type representing the token kinds values.
|
|
2085
|
+
*
|
|
2086
|
+
* @deprecated Please use `TokenKind`. Will be remove in v17.
|
|
2141
2087
|
*/
|
|
2142
2088
|
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
return false;
|
|
2169
|
-
};
|
|
2170
|
-
|
|
2171
|
-
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); } }
|
|
2172
|
-
|
|
2173
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
2174
|
-
|
|
2175
|
-
/**
|
|
2176
|
-
* A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
|
|
2177
|
-
* optional, but they are useful for clients who store GraphQL documents in source files.
|
|
2178
|
-
* For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
|
|
2179
|
-
* be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
|
|
2180
|
-
* The `line` and `column` properties in `locationOffset` are 1-indexed.
|
|
2181
|
-
*/
|
|
2182
|
-
var Source = /*#__PURE__*/function () {
|
|
2183
|
-
function Source(body) {
|
|
2184
|
-
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GraphQL request';
|
|
2185
|
-
var locationOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
2186
|
-
line: 1,
|
|
2187
|
-
column: 1
|
|
2188
|
-
};
|
|
2189
|
-
typeof body === 'string' || devAssert(0, "Body must be a string. Received: ".concat(inspect(body), "."));
|
|
2190
|
-
this.body = body;
|
|
2191
|
-
this.name = name;
|
|
2192
|
-
this.locationOffset = locationOffset;
|
|
2193
|
-
this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.');
|
|
2194
|
-
this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.');
|
|
2195
|
-
} // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
_createClass(Source, [{
|
|
2199
|
-
key: SYMBOL_TO_STRING_TAG,
|
|
2200
|
-
get: function get() {
|
|
2201
|
-
return 'Source';
|
|
2202
|
-
}
|
|
2203
|
-
}]);
|
|
2204
|
-
|
|
2205
|
-
return Source;
|
|
2206
|
-
}();
|
|
2207
|
-
/**
|
|
2208
|
-
* Test if the given value is a Source object.
|
|
2209
|
-
*
|
|
2210
|
-
* @internal
|
|
2211
|
-
*/
|
|
2212
|
-
|
|
2213
|
-
// eslint-disable-next-line no-redeclare
|
|
2214
|
-
function isSource(source) {
|
|
2215
|
-
return instanceOf(source, Source);
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
/**
|
|
2219
|
-
* The set of allowed directive location values.
|
|
2220
|
-
*/
|
|
2221
|
-
var DirectiveLocation = Object.freeze({
|
|
2222
|
-
// Request Definitions
|
|
2223
|
-
QUERY: 'QUERY',
|
|
2224
|
-
MUTATION: 'MUTATION',
|
|
2225
|
-
SUBSCRIPTION: 'SUBSCRIPTION',
|
|
2226
|
-
FIELD: 'FIELD',
|
|
2227
|
-
FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',
|
|
2228
|
-
FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',
|
|
2229
|
-
INLINE_FRAGMENT: 'INLINE_FRAGMENT',
|
|
2230
|
-
VARIABLE_DEFINITION: 'VARIABLE_DEFINITION',
|
|
2231
|
-
// Type System Definitions
|
|
2232
|
-
SCHEMA: 'SCHEMA',
|
|
2233
|
-
SCALAR: 'SCALAR',
|
|
2234
|
-
OBJECT: 'OBJECT',
|
|
2235
|
-
FIELD_DEFINITION: 'FIELD_DEFINITION',
|
|
2236
|
-
ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',
|
|
2237
|
-
INTERFACE: 'INTERFACE',
|
|
2238
|
-
UNION: 'UNION',
|
|
2239
|
-
ENUM: 'ENUM',
|
|
2240
|
-
ENUM_VALUE: 'ENUM_VALUE',
|
|
2241
|
-
INPUT_OBJECT: 'INPUT_OBJECT',
|
|
2242
|
-
INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'
|
|
2243
|
-
});
|
|
2244
|
-
/**
|
|
2245
|
-
* The enum type representing the directive location values.
|
|
2246
|
-
*/
|
|
2247
|
-
|
|
2248
|
-
/**
|
|
2249
|
-
* Produces the value of a block string from its parsed raw value, similar to
|
|
2250
|
-
* CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
|
|
2251
|
-
*
|
|
2252
|
-
* This implements the GraphQL spec's BlockStringValue() static algorithm.
|
|
2253
|
-
*
|
|
2254
|
-
* @internal
|
|
2255
|
-
*/
|
|
2256
|
-
function dedentBlockStringValue(rawString) {
|
|
2257
|
-
// Expand a block string's raw value into independent lines.
|
|
2258
|
-
var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
|
|
2259
|
-
|
|
2260
|
-
var commonIndent = getBlockStringIndentation(rawString);
|
|
2261
|
-
|
|
2262
|
-
if (commonIndent !== 0) {
|
|
2263
|
-
for (var i = 1; i < lines.length; i++) {
|
|
2264
|
-
lines[i] = lines[i].slice(commonIndent);
|
|
2265
|
-
}
|
|
2266
|
-
} // Remove leading and trailing blank lines.
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
var startLine = 0;
|
|
2270
|
-
|
|
2271
|
-
while (startLine < lines.length && isBlank(lines[startLine])) {
|
|
2272
|
-
++startLine;
|
|
2273
|
-
}
|
|
2274
|
-
|
|
2275
|
-
var endLine = lines.length;
|
|
2276
|
-
|
|
2277
|
-
while (endLine > startLine && isBlank(lines[endLine - 1])) {
|
|
2278
|
-
--endLine;
|
|
2279
|
-
} // Return a string of the lines joined with U+000A.
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
return lines.slice(startLine, endLine).join('\n');
|
|
2283
|
-
}
|
|
2284
|
-
|
|
2285
|
-
function isBlank(str) {
|
|
2286
|
-
for (var i = 0; i < str.length; ++i) {
|
|
2287
|
-
if (str[i] !== ' ' && str[i] !== '\t') {
|
|
2288
|
-
return false;
|
|
2289
|
-
}
|
|
2290
|
-
}
|
|
2291
|
-
|
|
2292
|
-
return true;
|
|
2293
|
-
}
|
|
2294
|
-
/**
|
|
2295
|
-
* @internal
|
|
2296
|
-
*/
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
function getBlockStringIndentation(value) {
|
|
2300
|
-
var _commonIndent;
|
|
2301
|
-
|
|
2302
|
-
var isFirstLine = true;
|
|
2303
|
-
var isEmptyLine = true;
|
|
2304
|
-
var indent = 0;
|
|
2305
|
-
var commonIndent = null;
|
|
2306
|
-
|
|
2307
|
-
for (var i = 0; i < value.length; ++i) {
|
|
2308
|
-
switch (value.charCodeAt(i)) {
|
|
2309
|
-
case 13:
|
|
2310
|
-
// \r
|
|
2311
|
-
if (value.charCodeAt(i + 1) === 10) {
|
|
2312
|
-
++i; // skip \r\n as one symbol
|
|
2313
|
-
}
|
|
2314
|
-
|
|
2315
|
-
// falls through
|
|
2316
|
-
|
|
2317
|
-
case 10:
|
|
2318
|
-
// \n
|
|
2319
|
-
isFirstLine = false;
|
|
2320
|
-
isEmptyLine = true;
|
|
2321
|
-
indent = 0;
|
|
2322
|
-
break;
|
|
2323
|
-
|
|
2324
|
-
case 9: // \t
|
|
2325
|
-
|
|
2326
|
-
case 32:
|
|
2327
|
-
// <space>
|
|
2328
|
-
++indent;
|
|
2329
|
-
break;
|
|
2330
|
-
|
|
2331
|
-
default:
|
|
2332
|
-
if (isEmptyLine && !isFirstLine && (commonIndent === null || indent < commonIndent)) {
|
|
2333
|
-
commonIndent = indent;
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2336
|
-
isEmptyLine = false;
|
|
2337
|
-
}
|
|
2338
|
-
}
|
|
2339
|
-
|
|
2340
|
-
return (_commonIndent = commonIndent) !== null && _commonIndent !== void 0 ? _commonIndent : 0;
|
|
2341
|
-
}
|
|
2089
|
+
(function (TokenKind) {
|
|
2090
|
+
TokenKind['SOF'] = '<SOF>';
|
|
2091
|
+
TokenKind['EOF'] = '<EOF>';
|
|
2092
|
+
TokenKind['BANG'] = '!';
|
|
2093
|
+
TokenKind['DOLLAR'] = '$';
|
|
2094
|
+
TokenKind['AMP'] = '&';
|
|
2095
|
+
TokenKind['PAREN_L'] = '(';
|
|
2096
|
+
TokenKind['PAREN_R'] = ')';
|
|
2097
|
+
TokenKind['SPREAD'] = '...';
|
|
2098
|
+
TokenKind['COLON'] = ':';
|
|
2099
|
+
TokenKind['EQUALS'] = '=';
|
|
2100
|
+
TokenKind['AT'] = '@';
|
|
2101
|
+
TokenKind['BRACKET_L'] = '[';
|
|
2102
|
+
TokenKind['BRACKET_R'] = ']';
|
|
2103
|
+
TokenKind['BRACE_L'] = '{';
|
|
2104
|
+
TokenKind['PIPE'] = '|';
|
|
2105
|
+
TokenKind['BRACE_R'] = '}';
|
|
2106
|
+
TokenKind['NAME'] = 'Name';
|
|
2107
|
+
TokenKind['INT'] = 'Int';
|
|
2108
|
+
TokenKind['FLOAT'] = 'Float';
|
|
2109
|
+
TokenKind['STRING'] = 'String';
|
|
2110
|
+
TokenKind['BLOCK_STRING'] = 'BlockString';
|
|
2111
|
+
TokenKind['COMMENT'] = 'Comment';
|
|
2112
|
+
})(TokenKind || (TokenKind = {}));
|
|
2342
2113
|
|
|
2343
2114
|
/**
|
|
2344
2115
|
* Given a Source object, creates a Lexer for that source.
|
|
@@ -2349,7 +2120,7 @@ function getBlockStringIndentation(value) {
|
|
|
2349
2120
|
* whenever called.
|
|
2350
2121
|
*/
|
|
2351
2122
|
|
|
2352
|
-
|
|
2123
|
+
class Lexer {
|
|
2353
2124
|
/**
|
|
2354
2125
|
* The previously focused non-ignored token.
|
|
2355
2126
|
*/
|
|
@@ -2365,64 +2136,143 @@ var Lexer = /*#__PURE__*/function () {
|
|
|
2365
2136
|
/**
|
|
2366
2137
|
* The character offset at which the current line begins.
|
|
2367
2138
|
*/
|
|
2368
|
-
|
|
2369
|
-
|
|
2139
|
+
constructor(source) {
|
|
2140
|
+
const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0);
|
|
2370
2141
|
this.source = source;
|
|
2371
2142
|
this.lastToken = startOfFileToken;
|
|
2372
2143
|
this.token = startOfFileToken;
|
|
2373
2144
|
this.line = 1;
|
|
2374
2145
|
this.lineStart = 0;
|
|
2375
2146
|
}
|
|
2147
|
+
|
|
2148
|
+
get [Symbol.toStringTag]() {
|
|
2149
|
+
return 'Lexer';
|
|
2150
|
+
}
|
|
2376
2151
|
/**
|
|
2377
2152
|
* Advances the token stream to the next non-ignored token.
|
|
2378
2153
|
*/
|
|
2379
2154
|
|
|
2380
|
-
|
|
2381
|
-
var _proto = Lexer.prototype;
|
|
2382
|
-
|
|
2383
|
-
_proto.advance = function advance() {
|
|
2155
|
+
advance() {
|
|
2384
2156
|
this.lastToken = this.token;
|
|
2385
|
-
|
|
2157
|
+
const token = (this.token = this.lookahead());
|
|
2386
2158
|
return token;
|
|
2387
2159
|
}
|
|
2388
2160
|
/**
|
|
2389
2161
|
* Looks ahead and returns the next non-ignored token, but does not change
|
|
2390
2162
|
* the state of Lexer.
|
|
2391
2163
|
*/
|
|
2392
|
-
;
|
|
2393
2164
|
|
|
2394
|
-
|
|
2395
|
-
|
|
2165
|
+
lookahead() {
|
|
2166
|
+
let token = this.token;
|
|
2396
2167
|
|
|
2397
2168
|
if (token.kind !== TokenKind.EOF) {
|
|
2398
2169
|
do {
|
|
2399
|
-
|
|
2170
|
+
if (token.next) {
|
|
2171
|
+
token = token.next;
|
|
2172
|
+
} else {
|
|
2173
|
+
// Read the next token and form a link in the token linked-list.
|
|
2174
|
+
const nextToken = readNextToken(this, token.end); // @ts-expect-error next is only mutable during parsing.
|
|
2400
2175
|
|
|
2401
|
-
|
|
2402
|
-
|
|
2176
|
+
token.next = nextToken; // @ts-expect-error prev is only mutable during parsing.
|
|
2177
|
+
|
|
2178
|
+
nextToken.prev = token;
|
|
2179
|
+
token = nextToken;
|
|
2180
|
+
}
|
|
2403
2181
|
} while (token.kind === TokenKind.COMMENT);
|
|
2404
2182
|
}
|
|
2405
2183
|
|
|
2406
2184
|
return token;
|
|
2407
|
-
}
|
|
2408
|
-
|
|
2409
|
-
return Lexer;
|
|
2410
|
-
}();
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2411
2187
|
/**
|
|
2412
2188
|
* @internal
|
|
2413
2189
|
*/
|
|
2414
2190
|
|
|
2415
2191
|
function isPunctuatorTokenKind(kind) {
|
|
2416
|
-
return
|
|
2192
|
+
return (
|
|
2193
|
+
kind === TokenKind.BANG ||
|
|
2194
|
+
kind === TokenKind.DOLLAR ||
|
|
2195
|
+
kind === TokenKind.AMP ||
|
|
2196
|
+
kind === TokenKind.PAREN_L ||
|
|
2197
|
+
kind === TokenKind.PAREN_R ||
|
|
2198
|
+
kind === TokenKind.SPREAD ||
|
|
2199
|
+
kind === TokenKind.COLON ||
|
|
2200
|
+
kind === TokenKind.EQUALS ||
|
|
2201
|
+
kind === TokenKind.AT ||
|
|
2202
|
+
kind === TokenKind.BRACKET_L ||
|
|
2203
|
+
kind === TokenKind.BRACKET_R ||
|
|
2204
|
+
kind === TokenKind.BRACE_L ||
|
|
2205
|
+
kind === TokenKind.PIPE ||
|
|
2206
|
+
kind === TokenKind.BRACE_R
|
|
2207
|
+
);
|
|
2417
2208
|
}
|
|
2209
|
+
/**
|
|
2210
|
+
* A Unicode scalar value is any Unicode code point except surrogate code
|
|
2211
|
+
* points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and
|
|
2212
|
+
* 0xE000 to 0x10FFFF.
|
|
2213
|
+
*
|
|
2214
|
+
* SourceCharacter ::
|
|
2215
|
+
* - "Any Unicode scalar value"
|
|
2216
|
+
*/
|
|
2418
2217
|
|
|
2419
|
-
function
|
|
2420
|
-
return (
|
|
2421
|
-
|
|
2422
|
-
code < 0x007f ? JSON.stringify(String.fromCharCode(code)) : // Otherwise print the escaped form.
|
|
2423
|
-
"\"\\u".concat(('00' + code.toString(16).toUpperCase()).slice(-4), "\"")
|
|
2218
|
+
function isUnicodeScalarValue(code) {
|
|
2219
|
+
return (
|
|
2220
|
+
(code >= 0x0000 && code <= 0xd7ff) || (code >= 0xe000 && code <= 0x10ffff)
|
|
2424
2221
|
);
|
|
2425
2222
|
}
|
|
2223
|
+
/**
|
|
2224
|
+
* The GraphQL specification defines source text as a sequence of unicode scalar
|
|
2225
|
+
* values (which Unicode defines to exclude surrogate code points). However
|
|
2226
|
+
* JavaScript defines strings as a sequence of UTF-16 code units which may
|
|
2227
|
+
* include surrogates. A surrogate pair is a valid source character as it
|
|
2228
|
+
* encodes a supplementary code point (above U+FFFF), but unpaired surrogate
|
|
2229
|
+
* code points are not valid source characters.
|
|
2230
|
+
*/
|
|
2231
|
+
|
|
2232
|
+
function isSupplementaryCodePoint(body, location) {
|
|
2233
|
+
return (
|
|
2234
|
+
isLeadingSurrogate(body.charCodeAt(location)) &&
|
|
2235
|
+
isTrailingSurrogate(body.charCodeAt(location + 1))
|
|
2236
|
+
);
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
function isLeadingSurrogate(code) {
|
|
2240
|
+
return code >= 0xd800 && code <= 0xdbff;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
function isTrailingSurrogate(code) {
|
|
2244
|
+
return code >= 0xdc00 && code <= 0xdfff;
|
|
2245
|
+
}
|
|
2246
|
+
/**
|
|
2247
|
+
* Prints the code point (or end of file reference) at a given location in a
|
|
2248
|
+
* source for use in error messages.
|
|
2249
|
+
*
|
|
2250
|
+
* Printable ASCII is printed quoted, while other points are printed in Unicode
|
|
2251
|
+
* code point form (ie. U+1234).
|
|
2252
|
+
*/
|
|
2253
|
+
|
|
2254
|
+
function printCodePointAt(lexer, location) {
|
|
2255
|
+
const code = lexer.source.body.codePointAt(location);
|
|
2256
|
+
|
|
2257
|
+
if (code === undefined) {
|
|
2258
|
+
return TokenKind.EOF;
|
|
2259
|
+
} else if (code >= 0x0020 && code <= 0x007e) {
|
|
2260
|
+
// Printable ASCII
|
|
2261
|
+
const char = String.fromCodePoint(code);
|
|
2262
|
+
return char === '"' ? "'\"'" : `"${char}"`;
|
|
2263
|
+
} // Unicode code point
|
|
2264
|
+
|
|
2265
|
+
return 'U+' + code.toString(16).toUpperCase().padStart(4, '0');
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Create a token with line and column location information.
|
|
2269
|
+
*/
|
|
2270
|
+
|
|
2271
|
+
function createToken(lexer, kind, start, end, value) {
|
|
2272
|
+
const line = lexer.line;
|
|
2273
|
+
const col = 1 + start - lexer.lineStart;
|
|
2274
|
+
return new Token(kind, start, end, line, col, value);
|
|
2275
|
+
}
|
|
2426
2276
|
/**
|
|
2427
2277
|
* Gets the next token from the source starting at the given position.
|
|
2428
2278
|
*
|
|
@@ -2431,586 +2281,947 @@ function printCharCode(code) {
|
|
|
2431
2281
|
* complicated tokens.
|
|
2432
2282
|
*/
|
|
2433
2283
|
|
|
2284
|
+
function readNextToken(lexer, start) {
|
|
2285
|
+
const body = lexer.source.body;
|
|
2286
|
+
const bodyLength = body.length;
|
|
2287
|
+
let position = start;
|
|
2434
2288
|
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
var body = source.body;
|
|
2438
|
-
var bodyLength = body.length;
|
|
2439
|
-
var pos = prev.end;
|
|
2440
|
-
|
|
2441
|
-
while (pos < bodyLength) {
|
|
2442
|
-
var code = body.charCodeAt(pos);
|
|
2443
|
-
var _line = lexer.line;
|
|
2444
|
-
|
|
2445
|
-
var _col = 1 + pos - lexer.lineStart; // SourceCharacter
|
|
2446
|
-
|
|
2289
|
+
while (position < bodyLength) {
|
|
2290
|
+
const code = body.charCodeAt(position); // SourceCharacter
|
|
2447
2291
|
|
|
2448
2292
|
switch (code) {
|
|
2293
|
+
// Ignored ::
|
|
2294
|
+
// - UnicodeBOM
|
|
2295
|
+
// - WhiteSpace
|
|
2296
|
+
// - LineTerminator
|
|
2297
|
+
// - Comment
|
|
2298
|
+
// - Comma
|
|
2299
|
+
//
|
|
2300
|
+
// UnicodeBOM :: "Byte Order Mark (U+FEFF)"
|
|
2301
|
+
//
|
|
2302
|
+
// WhiteSpace ::
|
|
2303
|
+
// - "Horizontal Tab (U+0009)"
|
|
2304
|
+
// - "Space (U+0020)"
|
|
2305
|
+
//
|
|
2306
|
+
// Comma :: ,
|
|
2449
2307
|
case 0xfeff: // <BOM>
|
|
2450
2308
|
|
|
2451
|
-
case
|
|
2309
|
+
case 0x0009: // \t
|
|
2452
2310
|
|
|
2453
|
-
case
|
|
2311
|
+
case 0x0020: // <space>
|
|
2454
2312
|
|
|
2455
|
-
case
|
|
2456
|
-
//
|
|
2457
|
-
++
|
|
2313
|
+
case 0x002c:
|
|
2314
|
+
// ,
|
|
2315
|
+
++position;
|
|
2458
2316
|
continue;
|
|
2317
|
+
// LineTerminator ::
|
|
2318
|
+
// - "New Line (U+000A)"
|
|
2319
|
+
// - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"]
|
|
2320
|
+
// - "Carriage Return (U+000D)" "New Line (U+000A)"
|
|
2459
2321
|
|
|
2460
|
-
case
|
|
2461
|
-
//
|
|
2462
|
-
++
|
|
2322
|
+
case 0x000a:
|
|
2323
|
+
// \n
|
|
2324
|
+
++position;
|
|
2463
2325
|
++lexer.line;
|
|
2464
|
-
lexer.lineStart =
|
|
2326
|
+
lexer.lineStart = position;
|
|
2465
2327
|
continue;
|
|
2466
2328
|
|
|
2467
|
-
case
|
|
2468
|
-
//
|
|
2469
|
-
if (body.charCodeAt(
|
|
2470
|
-
|
|
2329
|
+
case 0x000d:
|
|
2330
|
+
// \r
|
|
2331
|
+
if (body.charCodeAt(position + 1) === 0x000a) {
|
|
2332
|
+
position += 2;
|
|
2471
2333
|
} else {
|
|
2472
|
-
++
|
|
2334
|
+
++position;
|
|
2473
2335
|
}
|
|
2474
2336
|
|
|
2475
2337
|
++lexer.line;
|
|
2476
|
-
lexer.lineStart =
|
|
2338
|
+
lexer.lineStart = position;
|
|
2477
2339
|
continue;
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2340
|
+
// Comment
|
|
2341
|
+
|
|
2342
|
+
case 0x0023:
|
|
2343
|
+
// #
|
|
2344
|
+
return readComment(lexer, position);
|
|
2345
|
+
// Token ::
|
|
2346
|
+
// - Punctuator
|
|
2347
|
+
// - Name
|
|
2348
|
+
// - IntValue
|
|
2349
|
+
// - FloatValue
|
|
2350
|
+
// - StringValue
|
|
2351
|
+
//
|
|
2352
|
+
// Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
|
|
2353
|
+
|
|
2354
|
+
case 0x0021:
|
|
2355
|
+
// !
|
|
2356
|
+
return createToken(lexer, TokenKind.BANG, position, position + 1);
|
|
2357
|
+
|
|
2358
|
+
case 0x0024:
|
|
2359
|
+
// $
|
|
2360
|
+
return createToken(lexer, TokenKind.DOLLAR, position, position + 1);
|
|
2361
|
+
|
|
2362
|
+
case 0x0026:
|
|
2363
|
+
// &
|
|
2364
|
+
return createToken(lexer, TokenKind.AMP, position, position + 1);
|
|
2365
|
+
|
|
2366
|
+
case 0x0028:
|
|
2367
|
+
// (
|
|
2368
|
+
return createToken(lexer, TokenKind.PAREN_L, position, position + 1);
|
|
2369
|
+
|
|
2370
|
+
case 0x0029:
|
|
2371
|
+
// )
|
|
2372
|
+
return createToken(lexer, TokenKind.PAREN_R, position, position + 1);
|
|
2373
|
+
|
|
2374
|
+
case 0x002e:
|
|
2375
|
+
// .
|
|
2376
|
+
if (
|
|
2377
|
+
body.charCodeAt(position + 1) === 0x002e &&
|
|
2378
|
+
body.charCodeAt(position + 2) === 0x002e
|
|
2379
|
+
) {
|
|
2380
|
+
return createToken(lexer, TokenKind.SPREAD, position, position + 3);
|
|
2507
2381
|
}
|
|
2508
2382
|
|
|
2509
2383
|
break;
|
|
2510
2384
|
|
|
2511
|
-
case
|
|
2512
|
-
//
|
|
2513
|
-
return
|
|
2385
|
+
case 0x003a:
|
|
2386
|
+
// :
|
|
2387
|
+
return createToken(lexer, TokenKind.COLON, position, position + 1);
|
|
2514
2388
|
|
|
2515
|
-
case
|
|
2516
|
-
//
|
|
2517
|
-
return
|
|
2389
|
+
case 0x003d:
|
|
2390
|
+
// =
|
|
2391
|
+
return createToken(lexer, TokenKind.EQUALS, position, position + 1);
|
|
2518
2392
|
|
|
2519
|
-
case
|
|
2520
|
-
//
|
|
2521
|
-
return
|
|
2393
|
+
case 0x0040:
|
|
2394
|
+
// @
|
|
2395
|
+
return createToken(lexer, TokenKind.AT, position, position + 1);
|
|
2522
2396
|
|
|
2523
|
-
case
|
|
2524
|
-
//
|
|
2525
|
-
return
|
|
2397
|
+
case 0x005b:
|
|
2398
|
+
// [
|
|
2399
|
+
return createToken(lexer, TokenKind.BRACKET_L, position, position + 1);
|
|
2526
2400
|
|
|
2527
|
-
case
|
|
2528
|
-
//
|
|
2529
|
-
return
|
|
2401
|
+
case 0x005d:
|
|
2402
|
+
// ]
|
|
2403
|
+
return createToken(lexer, TokenKind.BRACKET_R, position, position + 1);
|
|
2530
2404
|
|
|
2531
|
-
case
|
|
2405
|
+
case 0x007b:
|
|
2532
2406
|
// {
|
|
2533
|
-
return
|
|
2407
|
+
return createToken(lexer, TokenKind.BRACE_L, position, position + 1);
|
|
2534
2408
|
|
|
2535
|
-
case
|
|
2409
|
+
case 0x007c:
|
|
2536
2410
|
// |
|
|
2537
|
-
return
|
|
2411
|
+
return createToken(lexer, TokenKind.PIPE, position, position + 1);
|
|
2538
2412
|
|
|
2539
|
-
case
|
|
2413
|
+
case 0x007d:
|
|
2540
2414
|
// }
|
|
2541
|
-
return
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2415
|
+
return createToken(lexer, TokenKind.BRACE_R, position, position + 1);
|
|
2416
|
+
// StringValue
|
|
2417
|
+
|
|
2418
|
+
case 0x0022:
|
|
2419
|
+
// "
|
|
2420
|
+
if (
|
|
2421
|
+
body.charCodeAt(position + 1) === 0x0022 &&
|
|
2422
|
+
body.charCodeAt(position + 2) === 0x0022
|
|
2423
|
+
) {
|
|
2424
|
+
return readBlockString(lexer, position);
|
|
2547
2425
|
}
|
|
2548
2426
|
|
|
2549
|
-
return readString(
|
|
2550
|
-
|
|
2551
|
-
case 45: // -
|
|
2552
|
-
|
|
2553
|
-
case 48: // 0
|
|
2427
|
+
return readString(lexer, position);
|
|
2428
|
+
} // IntValue | FloatValue (Digit | -)
|
|
2554
2429
|
|
|
2555
|
-
|
|
2430
|
+
if (isDigit(code) || code === 0x002d) {
|
|
2431
|
+
return readNumber(lexer, position, code);
|
|
2432
|
+
} // Name
|
|
2556
2433
|
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
case 52: // 4
|
|
2562
|
-
|
|
2563
|
-
case 53: // 5
|
|
2434
|
+
if (isNameStart(code)) {
|
|
2435
|
+
return readName(lexer, position);
|
|
2436
|
+
}
|
|
2564
2437
|
|
|
2565
|
-
|
|
2438
|
+
throw syntaxError(
|
|
2439
|
+
lexer.source,
|
|
2440
|
+
position,
|
|
2441
|
+
code === 0x0027
|
|
2442
|
+
? 'Unexpected single quote character (\'), did you mean to use a double quote (")?'
|
|
2443
|
+
: isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position)
|
|
2444
|
+
? `Unexpected character: ${printCodePointAt(lexer, position)}.`
|
|
2445
|
+
: `Invalid character: ${printCodePointAt(lexer, position)}.`,
|
|
2446
|
+
);
|
|
2447
|
+
}
|
|
2566
2448
|
|
|
2567
|
-
|
|
2449
|
+
return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength);
|
|
2450
|
+
}
|
|
2451
|
+
/**
|
|
2452
|
+
* Reads a comment token from the source file.
|
|
2453
|
+
*
|
|
2454
|
+
* ```
|
|
2455
|
+
* Comment :: # CommentChar* [lookahead != CommentChar]
|
|
2456
|
+
*
|
|
2457
|
+
* CommentChar :: SourceCharacter but not LineTerminator
|
|
2458
|
+
* ```
|
|
2459
|
+
*/
|
|
2568
2460
|
|
|
2569
|
-
|
|
2461
|
+
function readComment(lexer, start) {
|
|
2462
|
+
const body = lexer.source.body;
|
|
2463
|
+
const bodyLength = body.length;
|
|
2464
|
+
let position = start + 1;
|
|
2570
2465
|
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
return readNumber(source, pos, code, _line, _col, prev);
|
|
2466
|
+
while (position < bodyLength) {
|
|
2467
|
+
const code = body.charCodeAt(position); // LineTerminator (\n | \r)
|
|
2574
2468
|
|
|
2575
|
-
|
|
2469
|
+
if (code === 0x000a || code === 0x000d) {
|
|
2470
|
+
break;
|
|
2471
|
+
} // SourceCharacter
|
|
2576
2472
|
|
|
2577
|
-
|
|
2473
|
+
if (isUnicodeScalarValue(code)) {
|
|
2474
|
+
++position;
|
|
2475
|
+
} else if (isSupplementaryCodePoint(body, position)) {
|
|
2476
|
+
position += 2;
|
|
2477
|
+
} else {
|
|
2478
|
+
break;
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2578
2481
|
|
|
2579
|
-
|
|
2482
|
+
return createToken(
|
|
2483
|
+
lexer,
|
|
2484
|
+
TokenKind.COMMENT,
|
|
2485
|
+
start,
|
|
2486
|
+
position,
|
|
2487
|
+
body.slice(start + 1, position),
|
|
2488
|
+
);
|
|
2489
|
+
}
|
|
2490
|
+
/**
|
|
2491
|
+
* Reads a number token from the source file, either a FloatValue or an IntValue
|
|
2492
|
+
* depending on whether a FractionalPart or ExponentPart is encountered.
|
|
2493
|
+
*
|
|
2494
|
+
* ```
|
|
2495
|
+
* IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}]
|
|
2496
|
+
*
|
|
2497
|
+
* IntegerPart ::
|
|
2498
|
+
* - NegativeSign? 0
|
|
2499
|
+
* - NegativeSign? NonZeroDigit Digit*
|
|
2500
|
+
*
|
|
2501
|
+
* NegativeSign :: -
|
|
2502
|
+
*
|
|
2503
|
+
* NonZeroDigit :: Digit but not `0`
|
|
2504
|
+
*
|
|
2505
|
+
* FloatValue ::
|
|
2506
|
+
* - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}]
|
|
2507
|
+
* - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}]
|
|
2508
|
+
* - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}]
|
|
2509
|
+
*
|
|
2510
|
+
* FractionalPart :: . Digit+
|
|
2511
|
+
*
|
|
2512
|
+
* ExponentPart :: ExponentIndicator Sign? Digit+
|
|
2513
|
+
*
|
|
2514
|
+
* ExponentIndicator :: one of `e` `E`
|
|
2515
|
+
*
|
|
2516
|
+
* Sign :: one of + -
|
|
2517
|
+
* ```
|
|
2518
|
+
*/
|
|
2580
2519
|
|
|
2581
|
-
|
|
2520
|
+
function readNumber(lexer, start, firstCode) {
|
|
2521
|
+
const body = lexer.source.body;
|
|
2522
|
+
let position = start;
|
|
2523
|
+
let code = firstCode;
|
|
2524
|
+
let isFloat = false; // NegativeSign (-)
|
|
2582
2525
|
|
|
2583
|
-
|
|
2526
|
+
if (code === 0x002d) {
|
|
2527
|
+
code = body.charCodeAt(++position);
|
|
2528
|
+
} // Zero (0)
|
|
2584
2529
|
|
|
2585
|
-
|
|
2530
|
+
if (code === 0x0030) {
|
|
2531
|
+
code = body.charCodeAt(++position);
|
|
2586
2532
|
|
|
2587
|
-
|
|
2533
|
+
if (isDigit(code)) {
|
|
2534
|
+
throw syntaxError(
|
|
2535
|
+
lexer.source,
|
|
2536
|
+
position,
|
|
2537
|
+
`Invalid number, unexpected digit after 0: ${printCodePointAt(
|
|
2538
|
+
lexer,
|
|
2539
|
+
position,
|
|
2540
|
+
)}.`,
|
|
2541
|
+
);
|
|
2542
|
+
}
|
|
2543
|
+
} else {
|
|
2544
|
+
position = readDigits(lexer, position, code);
|
|
2545
|
+
code = body.charCodeAt(position);
|
|
2546
|
+
} // Full stop (.)
|
|
2588
2547
|
|
|
2589
|
-
|
|
2548
|
+
if (code === 0x002e) {
|
|
2549
|
+
isFloat = true;
|
|
2550
|
+
code = body.charCodeAt(++position);
|
|
2551
|
+
position = readDigits(lexer, position, code);
|
|
2552
|
+
code = body.charCodeAt(position);
|
|
2553
|
+
} // E e
|
|
2590
2554
|
|
|
2591
|
-
|
|
2555
|
+
if (code === 0x0045 || code === 0x0065) {
|
|
2556
|
+
isFloat = true;
|
|
2557
|
+
code = body.charCodeAt(++position); // + -
|
|
2592
2558
|
|
|
2593
|
-
|
|
2559
|
+
if (code === 0x002b || code === 0x002d) {
|
|
2560
|
+
code = body.charCodeAt(++position);
|
|
2561
|
+
}
|
|
2594
2562
|
|
|
2595
|
-
|
|
2563
|
+
position = readDigits(lexer, position, code);
|
|
2564
|
+
code = body.charCodeAt(position);
|
|
2565
|
+
} // Numbers cannot be followed by . or NameStart
|
|
2596
2566
|
|
|
2597
|
-
|
|
2567
|
+
if (code === 0x002e || isNameStart(code)) {
|
|
2568
|
+
throw syntaxError(
|
|
2569
|
+
lexer.source,
|
|
2570
|
+
position,
|
|
2571
|
+
`Invalid number, expected digit but got: ${printCodePointAt(
|
|
2572
|
+
lexer,
|
|
2573
|
+
position,
|
|
2574
|
+
)}.`,
|
|
2575
|
+
);
|
|
2576
|
+
}
|
|
2598
2577
|
|
|
2599
|
-
|
|
2578
|
+
return createToken(
|
|
2579
|
+
lexer,
|
|
2580
|
+
isFloat ? TokenKind.FLOAT : TokenKind.INT,
|
|
2581
|
+
start,
|
|
2582
|
+
position,
|
|
2583
|
+
body.slice(start, position),
|
|
2584
|
+
);
|
|
2585
|
+
}
|
|
2586
|
+
/**
|
|
2587
|
+
* Returns the new position in the source after reading one or more digits.
|
|
2588
|
+
*/
|
|
2600
2589
|
|
|
2601
|
-
|
|
2590
|
+
function readDigits(lexer, start, firstCode) {
|
|
2591
|
+
if (!isDigit(firstCode)) {
|
|
2592
|
+
throw syntaxError(
|
|
2593
|
+
lexer.source,
|
|
2594
|
+
start,
|
|
2595
|
+
`Invalid number, expected digit but got: ${printCodePointAt(
|
|
2596
|
+
lexer,
|
|
2597
|
+
start,
|
|
2598
|
+
)}.`,
|
|
2599
|
+
);
|
|
2600
|
+
}
|
|
2602
2601
|
|
|
2603
|
-
|
|
2602
|
+
const body = lexer.source.body;
|
|
2603
|
+
let position = start + 1; // +1 to skip first firstCode
|
|
2604
2604
|
|
|
2605
|
-
|
|
2605
|
+
while (isDigit(body.charCodeAt(position))) {
|
|
2606
|
+
++position;
|
|
2607
|
+
}
|
|
2606
2608
|
|
|
2607
|
-
|
|
2609
|
+
return position;
|
|
2610
|
+
}
|
|
2611
|
+
/**
|
|
2612
|
+
* Reads a single-quote string token from the source file.
|
|
2613
|
+
*
|
|
2614
|
+
* ```
|
|
2615
|
+
* StringValue ::
|
|
2616
|
+
* - `""` [lookahead != `"`]
|
|
2617
|
+
* - `"` StringCharacter+ `"`
|
|
2618
|
+
*
|
|
2619
|
+
* StringCharacter ::
|
|
2620
|
+
* - SourceCharacter but not `"` or `\` or LineTerminator
|
|
2621
|
+
* - `\u` EscapedUnicode
|
|
2622
|
+
* - `\` EscapedCharacter
|
|
2623
|
+
*
|
|
2624
|
+
* EscapedUnicode ::
|
|
2625
|
+
* - `{` HexDigit+ `}`
|
|
2626
|
+
* - HexDigit HexDigit HexDigit HexDigit
|
|
2627
|
+
*
|
|
2628
|
+
* EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t`
|
|
2629
|
+
* ```
|
|
2630
|
+
*/
|
|
2608
2631
|
|
|
2609
|
-
|
|
2632
|
+
function readString(lexer, start) {
|
|
2633
|
+
const body = lexer.source.body;
|
|
2634
|
+
const bodyLength = body.length;
|
|
2635
|
+
let position = start + 1;
|
|
2636
|
+
let chunkStart = position;
|
|
2637
|
+
let value = '';
|
|
2610
2638
|
|
|
2611
|
-
|
|
2639
|
+
while (position < bodyLength) {
|
|
2640
|
+
const code = body.charCodeAt(position); // Closing Quote (")
|
|
2612
2641
|
|
|
2613
|
-
|
|
2642
|
+
if (code === 0x0022) {
|
|
2643
|
+
value += body.slice(chunkStart, position);
|
|
2644
|
+
return createToken(lexer, TokenKind.STRING, start, position + 1, value);
|
|
2645
|
+
} // Escape Sequence (\)
|
|
2614
2646
|
|
|
2615
|
-
|
|
2647
|
+
if (code === 0x005c) {
|
|
2648
|
+
value += body.slice(chunkStart, position);
|
|
2649
|
+
const escape =
|
|
2650
|
+
body.charCodeAt(position + 1) === 0x0075 // u
|
|
2651
|
+
? body.charCodeAt(position + 2) === 0x007b // {
|
|
2652
|
+
? readEscapedUnicodeVariableWidth(lexer, position)
|
|
2653
|
+
: readEscapedUnicodeFixedWidth(lexer, position)
|
|
2654
|
+
: readEscapedCharacter(lexer, position);
|
|
2655
|
+
value += escape.value;
|
|
2656
|
+
position += escape.size;
|
|
2657
|
+
chunkStart = position;
|
|
2658
|
+
continue;
|
|
2659
|
+
} // LineTerminator (\n | \r)
|
|
2616
2660
|
|
|
2617
|
-
|
|
2661
|
+
if (code === 0x000a || code === 0x000d) {
|
|
2662
|
+
break;
|
|
2663
|
+
} // SourceCharacter
|
|
2618
2664
|
|
|
2619
|
-
|
|
2665
|
+
if (isUnicodeScalarValue(code)) {
|
|
2666
|
+
++position;
|
|
2667
|
+
} else if (isSupplementaryCodePoint(body, position)) {
|
|
2668
|
+
position += 2;
|
|
2669
|
+
} else {
|
|
2670
|
+
throw syntaxError(
|
|
2671
|
+
lexer.source,
|
|
2672
|
+
position,
|
|
2673
|
+
`Invalid character within String: ${printCodePointAt(
|
|
2674
|
+
lexer,
|
|
2675
|
+
position,
|
|
2676
|
+
)}.`,
|
|
2677
|
+
);
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2620
2680
|
|
|
2621
|
-
|
|
2681
|
+
throw syntaxError(lexer.source, position, 'Unterminated string.');
|
|
2682
|
+
} // The string value and lexed size of an escape sequence.
|
|
2622
2683
|
|
|
2623
|
-
|
|
2684
|
+
function readEscapedUnicodeVariableWidth(lexer, position) {
|
|
2685
|
+
const body = lexer.source.body;
|
|
2686
|
+
let point = 0;
|
|
2687
|
+
let size = 3; // Cannot be larger than 12 chars (\u{00000000}).
|
|
2624
2688
|
|
|
2625
|
-
|
|
2689
|
+
while (size < 12) {
|
|
2690
|
+
const code = body.charCodeAt(position + size++); // Closing Brace (})
|
|
2626
2691
|
|
|
2627
|
-
|
|
2692
|
+
if (code === 0x007d) {
|
|
2693
|
+
// Must be at least 5 chars (\u{0}) and encode a Unicode scalar value.
|
|
2694
|
+
if (size < 5 || !isUnicodeScalarValue(point)) {
|
|
2695
|
+
break;
|
|
2696
|
+
}
|
|
2628
2697
|
|
|
2629
|
-
|
|
2698
|
+
return {
|
|
2699
|
+
value: String.fromCodePoint(point),
|
|
2700
|
+
size,
|
|
2701
|
+
};
|
|
2702
|
+
} // Append this hex digit to the code point.
|
|
2630
2703
|
|
|
2631
|
-
|
|
2704
|
+
point = (point << 4) | readHexDigit(code);
|
|
2632
2705
|
|
|
2633
|
-
|
|
2706
|
+
if (point < 0) {
|
|
2707
|
+
break;
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2634
2710
|
|
|
2635
|
-
|
|
2711
|
+
throw syntaxError(
|
|
2712
|
+
lexer.source,
|
|
2713
|
+
position,
|
|
2714
|
+
`Invalid Unicode escape sequence: "${body.slice(
|
|
2715
|
+
position,
|
|
2716
|
+
position + size,
|
|
2717
|
+
)}".`,
|
|
2718
|
+
);
|
|
2719
|
+
}
|
|
2636
2720
|
|
|
2637
|
-
|
|
2721
|
+
function readEscapedUnicodeFixedWidth(lexer, position) {
|
|
2722
|
+
const body = lexer.source.body;
|
|
2723
|
+
const code = read16BitHexCode(body, position + 2);
|
|
2638
2724
|
|
|
2639
|
-
|
|
2725
|
+
if (isUnicodeScalarValue(code)) {
|
|
2726
|
+
return {
|
|
2727
|
+
value: String.fromCodePoint(code),
|
|
2728
|
+
size: 6,
|
|
2729
|
+
};
|
|
2730
|
+
} // GraphQL allows JSON-style surrogate pair escape sequences, but only when
|
|
2731
|
+
// a valid pair is formed.
|
|
2732
|
+
|
|
2733
|
+
if (isLeadingSurrogate(code)) {
|
|
2734
|
+
// \u
|
|
2735
|
+
if (
|
|
2736
|
+
body.charCodeAt(position + 6) === 0x005c &&
|
|
2737
|
+
body.charCodeAt(position + 7) === 0x0075
|
|
2738
|
+
) {
|
|
2739
|
+
const trailingCode = read16BitHexCode(body, position + 8);
|
|
2740
|
+
|
|
2741
|
+
if (isTrailingSurrogate(trailingCode)) {
|
|
2742
|
+
// JavaScript defines strings as a sequence of UTF-16 code units and
|
|
2743
|
+
// encodes Unicode code points above U+FFFF using a surrogate pair of
|
|
2744
|
+
// code units. Since this is a surrogate pair escape sequence, just
|
|
2745
|
+
// include both codes into the JavaScript string value. Had JavaScript
|
|
2746
|
+
// not been internally based on UTF-16, then this surrogate pair would
|
|
2747
|
+
// be decoded to retrieve the supplementary code point.
|
|
2748
|
+
return {
|
|
2749
|
+
value: String.fromCodePoint(code, trailingCode),
|
|
2750
|
+
size: 12,
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2640
2755
|
|
|
2641
|
-
|
|
2756
|
+
throw syntaxError(
|
|
2757
|
+
lexer.source,
|
|
2758
|
+
position,
|
|
2759
|
+
`Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`,
|
|
2760
|
+
);
|
|
2761
|
+
}
|
|
2762
|
+
/**
|
|
2763
|
+
* Reads four hexadecimal characters and returns the positive integer that 16bit
|
|
2764
|
+
* hexadecimal string represents. For example, "000f" will return 15, and "dead"
|
|
2765
|
+
* will return 57005.
|
|
2766
|
+
*
|
|
2767
|
+
* Returns a negative number if any char was not a valid hexadecimal digit.
|
|
2768
|
+
*/
|
|
2642
2769
|
|
|
2643
|
-
|
|
2770
|
+
function read16BitHexCode(body, position) {
|
|
2771
|
+
// readHexDigit() returns -1 on error. ORing a negative value with any other
|
|
2772
|
+
// value always produces a negative value.
|
|
2773
|
+
return (
|
|
2774
|
+
(readHexDigit(body.charCodeAt(position)) << 12) |
|
|
2775
|
+
(readHexDigit(body.charCodeAt(position + 1)) << 8) |
|
|
2776
|
+
(readHexDigit(body.charCodeAt(position + 2)) << 4) |
|
|
2777
|
+
readHexDigit(body.charCodeAt(position + 3))
|
|
2778
|
+
);
|
|
2779
|
+
}
|
|
2780
|
+
/**
|
|
2781
|
+
* Reads a hexadecimal character and returns its positive integer value (0-15).
|
|
2782
|
+
*
|
|
2783
|
+
* '0' becomes 0, '9' becomes 9
|
|
2784
|
+
* 'A' becomes 10, 'F' becomes 15
|
|
2785
|
+
* 'a' becomes 10, 'f' becomes 15
|
|
2786
|
+
*
|
|
2787
|
+
* Returns -1 if the provided character code was not a valid hexadecimal digit.
|
|
2788
|
+
*
|
|
2789
|
+
* HexDigit :: one of
|
|
2790
|
+
* - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
|
|
2791
|
+
* - `A` `B` `C` `D` `E` `F`
|
|
2792
|
+
* - `a` `b` `c` `d` `e` `f`
|
|
2793
|
+
*/
|
|
2644
2794
|
|
|
2645
|
-
|
|
2795
|
+
function readHexDigit(code) {
|
|
2796
|
+
return code >= 0x0030 && code <= 0x0039 // 0-9
|
|
2797
|
+
? code - 0x0030
|
|
2798
|
+
: code >= 0x0041 && code <= 0x0046 // A-F
|
|
2799
|
+
? code - 0x0037
|
|
2800
|
+
: code >= 0x0061 && code <= 0x0066 // a-f
|
|
2801
|
+
? code - 0x0057
|
|
2802
|
+
: -1;
|
|
2803
|
+
}
|
|
2804
|
+
/**
|
|
2805
|
+
* | Escaped Character | Code Point | Character Name |
|
|
2806
|
+
* | ----------------- | ---------- | ---------------------------- |
|
|
2807
|
+
* | `"` | U+0022 | double quote |
|
|
2808
|
+
* | `\` | U+005C | reverse solidus (back slash) |
|
|
2809
|
+
* | `/` | U+002F | solidus (forward slash) |
|
|
2810
|
+
* | `b` | U+0008 | backspace |
|
|
2811
|
+
* | `f` | U+000C | form feed |
|
|
2812
|
+
* | `n` | U+000A | line feed (new line) |
|
|
2813
|
+
* | `r` | U+000D | carriage return |
|
|
2814
|
+
* | `t` | U+0009 | horizontal tab |
|
|
2815
|
+
*/
|
|
2646
2816
|
|
|
2647
|
-
|
|
2817
|
+
function readEscapedCharacter(lexer, position) {
|
|
2818
|
+
const body = lexer.source.body;
|
|
2819
|
+
const code = body.charCodeAt(position + 1);
|
|
2648
2820
|
|
|
2649
|
-
|
|
2821
|
+
switch (code) {
|
|
2822
|
+
case 0x0022:
|
|
2823
|
+
// "
|
|
2824
|
+
return {
|
|
2825
|
+
value: '\u0022',
|
|
2826
|
+
size: 2,
|
|
2827
|
+
};
|
|
2650
2828
|
|
|
2651
|
-
|
|
2829
|
+
case 0x005c:
|
|
2830
|
+
// \
|
|
2831
|
+
return {
|
|
2832
|
+
value: '\u005c',
|
|
2833
|
+
size: 2,
|
|
2834
|
+
};
|
|
2652
2835
|
|
|
2653
|
-
|
|
2836
|
+
case 0x002f:
|
|
2837
|
+
// /
|
|
2838
|
+
return {
|
|
2839
|
+
value: '\u002f',
|
|
2840
|
+
size: 2,
|
|
2841
|
+
};
|
|
2654
2842
|
|
|
2655
|
-
|
|
2843
|
+
case 0x0062:
|
|
2844
|
+
// b
|
|
2845
|
+
return {
|
|
2846
|
+
value: '\u0008',
|
|
2847
|
+
size: 2,
|
|
2848
|
+
};
|
|
2656
2849
|
|
|
2657
|
-
|
|
2850
|
+
case 0x0066:
|
|
2851
|
+
// f
|
|
2852
|
+
return {
|
|
2853
|
+
value: '\u000c',
|
|
2854
|
+
size: 2,
|
|
2855
|
+
};
|
|
2658
2856
|
|
|
2659
|
-
|
|
2857
|
+
case 0x006e:
|
|
2858
|
+
// n
|
|
2859
|
+
return {
|
|
2860
|
+
value: '\u000a',
|
|
2861
|
+
size: 2,
|
|
2862
|
+
};
|
|
2660
2863
|
|
|
2661
|
-
|
|
2864
|
+
case 0x0072:
|
|
2865
|
+
// r
|
|
2866
|
+
return {
|
|
2867
|
+
value: '\u000d',
|
|
2868
|
+
size: 2,
|
|
2869
|
+
};
|
|
2662
2870
|
|
|
2663
|
-
|
|
2871
|
+
case 0x0074:
|
|
2872
|
+
// t
|
|
2873
|
+
return {
|
|
2874
|
+
value: '\u0009',
|
|
2875
|
+
size: 2,
|
|
2876
|
+
};
|
|
2877
|
+
}
|
|
2664
2878
|
|
|
2665
|
-
|
|
2879
|
+
throw syntaxError(
|
|
2880
|
+
lexer.source,
|
|
2881
|
+
position,
|
|
2882
|
+
`Invalid character escape sequence: "${body.slice(
|
|
2883
|
+
position,
|
|
2884
|
+
position + 2,
|
|
2885
|
+
)}".`,
|
|
2886
|
+
);
|
|
2887
|
+
}
|
|
2888
|
+
/**
|
|
2889
|
+
* Reads a block string token from the source file.
|
|
2890
|
+
*
|
|
2891
|
+
* ```
|
|
2892
|
+
* StringValue ::
|
|
2893
|
+
* - `"""` BlockStringCharacter* `"""`
|
|
2894
|
+
*
|
|
2895
|
+
* BlockStringCharacter ::
|
|
2896
|
+
* - SourceCharacter but not `"""` or `\"""`
|
|
2897
|
+
* - `\"""`
|
|
2898
|
+
* ```
|
|
2899
|
+
*/
|
|
2666
2900
|
|
|
2667
|
-
|
|
2901
|
+
function readBlockString(lexer, start) {
|
|
2902
|
+
const body = lexer.source.body;
|
|
2903
|
+
const bodyLength = body.length;
|
|
2904
|
+
let lineStart = lexer.lineStart;
|
|
2905
|
+
let position = start + 3;
|
|
2906
|
+
let chunkStart = position;
|
|
2907
|
+
let currentLine = '';
|
|
2908
|
+
const blockLines = [];
|
|
2909
|
+
|
|
2910
|
+
while (position < bodyLength) {
|
|
2911
|
+
const code = body.charCodeAt(position); // Closing Triple-Quote (""")
|
|
2912
|
+
|
|
2913
|
+
if (
|
|
2914
|
+
code === 0x0022 &&
|
|
2915
|
+
body.charCodeAt(position + 1) === 0x0022 &&
|
|
2916
|
+
body.charCodeAt(position + 2) === 0x0022
|
|
2917
|
+
) {
|
|
2918
|
+
currentLine += body.slice(chunkStart, position);
|
|
2919
|
+
blockLines.push(currentLine);
|
|
2920
|
+
const token = createToken(
|
|
2921
|
+
lexer,
|
|
2922
|
+
TokenKind.BLOCK_STRING,
|
|
2923
|
+
start,
|
|
2924
|
+
position + 3, // Return a string of the lines joined with U+000A.
|
|
2925
|
+
dedentBlockStringLines(blockLines).join('\n'),
|
|
2926
|
+
);
|
|
2927
|
+
lexer.line += blockLines.length - 1;
|
|
2928
|
+
lexer.lineStart = lineStart;
|
|
2929
|
+
return token;
|
|
2930
|
+
} // Escaped Triple-Quote (\""")
|
|
2668
2931
|
|
|
2669
|
-
|
|
2932
|
+
if (
|
|
2933
|
+
code === 0x005c &&
|
|
2934
|
+
body.charCodeAt(position + 1) === 0x0022 &&
|
|
2935
|
+
body.charCodeAt(position + 2) === 0x0022 &&
|
|
2936
|
+
body.charCodeAt(position + 3) === 0x0022
|
|
2937
|
+
) {
|
|
2938
|
+
currentLine += body.slice(chunkStart, position);
|
|
2939
|
+
chunkStart = position + 1; // skip only slash
|
|
2670
2940
|
|
|
2671
|
-
|
|
2941
|
+
position += 4;
|
|
2942
|
+
continue;
|
|
2943
|
+
} // LineTerminator
|
|
2672
2944
|
|
|
2673
|
-
|
|
2945
|
+
if (code === 0x000a || code === 0x000d) {
|
|
2946
|
+
currentLine += body.slice(chunkStart, position);
|
|
2947
|
+
blockLines.push(currentLine);
|
|
2674
2948
|
|
|
2675
|
-
|
|
2949
|
+
if (code === 0x000d && body.charCodeAt(position + 1) === 0x000a) {
|
|
2950
|
+
position += 2;
|
|
2951
|
+
} else {
|
|
2952
|
+
++position;
|
|
2953
|
+
}
|
|
2676
2954
|
|
|
2677
|
-
|
|
2955
|
+
currentLine = '';
|
|
2956
|
+
chunkStart = position;
|
|
2957
|
+
lineStart = position;
|
|
2958
|
+
continue;
|
|
2959
|
+
} // SourceCharacter
|
|
2678
2960
|
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2961
|
+
if (isUnicodeScalarValue(code)) {
|
|
2962
|
+
++position;
|
|
2963
|
+
} else if (isSupplementaryCodePoint(body, position)) {
|
|
2964
|
+
position += 2;
|
|
2965
|
+
} else {
|
|
2966
|
+
throw syntaxError(
|
|
2967
|
+
lexer.source,
|
|
2968
|
+
position,
|
|
2969
|
+
`Invalid character within String: ${printCodePointAt(
|
|
2970
|
+
lexer,
|
|
2971
|
+
position,
|
|
2972
|
+
)}.`,
|
|
2973
|
+
);
|
|
2682
2974
|
}
|
|
2683
|
-
|
|
2684
|
-
throw syntaxError(source, pos, unexpectedCharacterMessage(code));
|
|
2685
2975
|
}
|
|
2686
2976
|
|
|
2687
|
-
|
|
2688
|
-
var col = 1 + pos - lexer.lineStart;
|
|
2689
|
-
return new Token(TokenKind.EOF, bodyLength, bodyLength, line, col, prev);
|
|
2977
|
+
throw syntaxError(lexer.source, position, 'Unterminated string.');
|
|
2690
2978
|
}
|
|
2691
2979
|
/**
|
|
2692
|
-
*
|
|
2980
|
+
* Reads an alphanumeric + underscore name from the source.
|
|
2981
|
+
*
|
|
2982
|
+
* ```
|
|
2983
|
+
* Name ::
|
|
2984
|
+
* - NameStart NameContinue* [lookahead != NameContinue]
|
|
2985
|
+
* ```
|
|
2693
2986
|
*/
|
|
2694
2987
|
|
|
2988
|
+
function readName(lexer, start) {
|
|
2989
|
+
const body = lexer.source.body;
|
|
2990
|
+
const bodyLength = body.length;
|
|
2991
|
+
let position = start + 1;
|
|
2695
2992
|
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
return "Cannot contain the invalid character ".concat(printCharCode(code), ".");
|
|
2699
|
-
}
|
|
2993
|
+
while (position < bodyLength) {
|
|
2994
|
+
const code = body.charCodeAt(position);
|
|
2700
2995
|
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2996
|
+
if (isNameContinue(code)) {
|
|
2997
|
+
++position;
|
|
2998
|
+
} else {
|
|
2999
|
+
break;
|
|
3000
|
+
}
|
|
2704
3001
|
}
|
|
2705
3002
|
|
|
2706
|
-
return
|
|
3003
|
+
return createToken(
|
|
3004
|
+
lexer,
|
|
3005
|
+
TokenKind.NAME,
|
|
3006
|
+
start,
|
|
3007
|
+
position,
|
|
3008
|
+
body.slice(start, position),
|
|
3009
|
+
);
|
|
2707
3010
|
}
|
|
2708
|
-
/**
|
|
2709
|
-
* Reads a comment token from the source file.
|
|
2710
|
-
*
|
|
2711
|
-
* #[\u0009\u0020-\uFFFF]*
|
|
2712
|
-
*/
|
|
2713
3011
|
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
var body = source.body;
|
|
2717
|
-
var code;
|
|
2718
|
-
var position = start;
|
|
2719
|
-
|
|
2720
|
-
do {
|
|
2721
|
-
code = body.charCodeAt(++position);
|
|
2722
|
-
} while (!isNaN(code) && ( // SourceCharacter but not LineTerminator
|
|
2723
|
-
code > 0x001f || code === 0x0009));
|
|
2724
|
-
|
|
2725
|
-
return new Token(TokenKind.COMMENT, start, position, line, col, prev, body.slice(start + 1, position));
|
|
2726
|
-
}
|
|
3012
|
+
const MAX_ARRAY_LENGTH = 10;
|
|
3013
|
+
const MAX_RECURSIVE_DEPTH = 2;
|
|
2727
3014
|
/**
|
|
2728
|
-
*
|
|
2729
|
-
* or an int depending on whether a decimal point appears.
|
|
2730
|
-
*
|
|
2731
|
-
* Int: -?(0|[1-9][0-9]*)
|
|
2732
|
-
* Float: -?(0|[1-9][0-9]*)(\.[0-9]+)?((E|e)(+|-)?[0-9]+)?
|
|
3015
|
+
* Used to print values in error messages.
|
|
2733
3016
|
*/
|
|
2734
3017
|
|
|
3018
|
+
function inspect(value) {
|
|
3019
|
+
return formatValue(value, []);
|
|
3020
|
+
}
|
|
2735
3021
|
|
|
2736
|
-
function
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
var isFloat = false;
|
|
3022
|
+
function formatValue(value, seenValues) {
|
|
3023
|
+
switch (typeof value) {
|
|
3024
|
+
case 'string':
|
|
3025
|
+
return JSON.stringify(value);
|
|
2741
3026
|
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
code = body.charCodeAt(++position);
|
|
2745
|
-
}
|
|
3027
|
+
case 'function':
|
|
3028
|
+
return value.name ? `[function ${value.name}]` : '[function]';
|
|
2746
3029
|
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
code = body.charCodeAt(++position);
|
|
3030
|
+
case 'object':
|
|
3031
|
+
return formatObjectValue(value, seenValues);
|
|
2750
3032
|
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
}
|
|
2754
|
-
} else {
|
|
2755
|
-
position = readDigits(source, position, code);
|
|
2756
|
-
code = body.charCodeAt(position);
|
|
3033
|
+
default:
|
|
3034
|
+
return String(value);
|
|
2757
3035
|
}
|
|
3036
|
+
}
|
|
2758
3037
|
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
code = body.charCodeAt(++position);
|
|
2763
|
-
position = readDigits(source, position, code);
|
|
2764
|
-
code = body.charCodeAt(position);
|
|
3038
|
+
function formatObjectValue(value, previouslySeenValues) {
|
|
3039
|
+
if (value === null) {
|
|
3040
|
+
return 'null';
|
|
2765
3041
|
}
|
|
2766
3042
|
|
|
2767
|
-
if (
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
code = body.charCodeAt(++position);
|
|
2771
|
-
|
|
2772
|
-
if (code === 43 || code === 45) {
|
|
2773
|
-
// + -
|
|
2774
|
-
code = body.charCodeAt(++position);
|
|
2775
|
-
}
|
|
3043
|
+
if (previouslySeenValues.includes(value)) {
|
|
3044
|
+
return '[Circular]';
|
|
3045
|
+
}
|
|
2776
3046
|
|
|
2777
|
-
|
|
2778
|
-
code = body.charCodeAt(position);
|
|
2779
|
-
} // Numbers cannot be followed by . or NameStart
|
|
3047
|
+
const seenValues = [...previouslySeenValues, value];
|
|
2780
3048
|
|
|
3049
|
+
if (isJSONable(value)) {
|
|
3050
|
+
const jsonValue = value.toJSON(); // check for infinite recursion
|
|
2781
3051
|
|
|
2782
|
-
|
|
2783
|
-
|
|
3052
|
+
if (jsonValue !== value) {
|
|
3053
|
+
return typeof jsonValue === 'string'
|
|
3054
|
+
? jsonValue
|
|
3055
|
+
: formatValue(jsonValue, seenValues);
|
|
3056
|
+
}
|
|
3057
|
+
} else if (Array.isArray(value)) {
|
|
3058
|
+
return formatArray(value, seenValues);
|
|
2784
3059
|
}
|
|
2785
3060
|
|
|
2786
|
-
return
|
|
3061
|
+
return formatObject(value, seenValues);
|
|
2787
3062
|
}
|
|
2788
|
-
/**
|
|
2789
|
-
* Returns the new position in the source after reading digits.
|
|
2790
|
-
*/
|
|
2791
|
-
|
|
2792
3063
|
|
|
2793
|
-
function
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
var code = firstCode;
|
|
3064
|
+
function isJSONable(value) {
|
|
3065
|
+
return typeof value.toJSON === 'function';
|
|
3066
|
+
}
|
|
2797
3067
|
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
do {
|
|
2801
|
-
code = body.charCodeAt(++position);
|
|
2802
|
-
} while (code >= 48 && code <= 57); // 0 - 9
|
|
3068
|
+
function formatObject(object, seenValues) {
|
|
3069
|
+
const entries = Object.entries(object);
|
|
2803
3070
|
|
|
3071
|
+
if (entries.length === 0) {
|
|
3072
|
+
return '{}';
|
|
3073
|
+
}
|
|
2804
3074
|
|
|
2805
|
-
|
|
3075
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
3076
|
+
return '[' + getObjectTag(object) + ']';
|
|
2806
3077
|
}
|
|
2807
3078
|
|
|
2808
|
-
|
|
3079
|
+
const properties = entries.map(
|
|
3080
|
+
([key, value]) => key + ': ' + formatValue(value, seenValues),
|
|
3081
|
+
);
|
|
3082
|
+
return '{ ' + properties.join(', ') + ' }';
|
|
2809
3083
|
}
|
|
2810
|
-
/**
|
|
2811
|
-
* Reads a string token from the source file.
|
|
2812
|
-
*
|
|
2813
|
-
* "([^"\\\u000A\u000D]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*"
|
|
2814
|
-
*/
|
|
2815
3084
|
|
|
3085
|
+
function formatArray(array, seenValues) {
|
|
3086
|
+
if (array.length === 0) {
|
|
3087
|
+
return '[]';
|
|
3088
|
+
}
|
|
2816
3089
|
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
var chunkStart = position;
|
|
2821
|
-
var code = 0;
|
|
2822
|
-
var value = '';
|
|
2823
|
-
|
|
2824
|
-
while (position < body.length && !isNaN(code = body.charCodeAt(position)) && // not LineTerminator
|
|
2825
|
-
code !== 0x000a && code !== 0x000d) {
|
|
2826
|
-
// Closing Quote (")
|
|
2827
|
-
if (code === 34) {
|
|
2828
|
-
value += body.slice(chunkStart, position);
|
|
2829
|
-
return new Token(TokenKind.STRING, start, position + 1, line, col, prev, value);
|
|
2830
|
-
} // SourceCharacter
|
|
3090
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
3091
|
+
return '[Array]';
|
|
3092
|
+
}
|
|
2831
3093
|
|
|
3094
|
+
const len = Math.min(MAX_ARRAY_LENGTH, array.length);
|
|
3095
|
+
const remaining = array.length - len;
|
|
3096
|
+
const items = [];
|
|
2832
3097
|
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
3098
|
+
for (let i = 0; i < len; ++i) {
|
|
3099
|
+
items.push(formatValue(array[i], seenValues));
|
|
3100
|
+
}
|
|
2836
3101
|
|
|
2837
|
-
|
|
3102
|
+
if (remaining === 1) {
|
|
3103
|
+
items.push('... 1 more item');
|
|
3104
|
+
} else if (remaining > 1) {
|
|
3105
|
+
items.push(`... ${remaining} more items`);
|
|
3106
|
+
}
|
|
2838
3107
|
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
value += body.slice(chunkStart, position - 1);
|
|
2842
|
-
code = body.charCodeAt(position);
|
|
2843
|
-
|
|
2844
|
-
switch (code) {
|
|
2845
|
-
case 34:
|
|
2846
|
-
value += '"';
|
|
2847
|
-
break;
|
|
2848
|
-
|
|
2849
|
-
case 47:
|
|
2850
|
-
value += '/';
|
|
2851
|
-
break;
|
|
2852
|
-
|
|
2853
|
-
case 92:
|
|
2854
|
-
value += '\\';
|
|
2855
|
-
break;
|
|
2856
|
-
|
|
2857
|
-
case 98:
|
|
2858
|
-
value += '\b';
|
|
2859
|
-
break;
|
|
2860
|
-
|
|
2861
|
-
case 102:
|
|
2862
|
-
value += '\f';
|
|
2863
|
-
break;
|
|
2864
|
-
|
|
2865
|
-
case 110:
|
|
2866
|
-
value += '\n';
|
|
2867
|
-
break;
|
|
2868
|
-
|
|
2869
|
-
case 114:
|
|
2870
|
-
value += '\r';
|
|
2871
|
-
break;
|
|
2872
|
-
|
|
2873
|
-
case 116:
|
|
2874
|
-
value += '\t';
|
|
2875
|
-
break;
|
|
2876
|
-
|
|
2877
|
-
case 117:
|
|
2878
|
-
{
|
|
2879
|
-
// uXXXX
|
|
2880
|
-
var charCode = uniCharCode(body.charCodeAt(position + 1), body.charCodeAt(position + 2), body.charCodeAt(position + 3), body.charCodeAt(position + 4));
|
|
2881
|
-
|
|
2882
|
-
if (charCode < 0) {
|
|
2883
|
-
var invalidSequence = body.slice(position + 1, position + 5);
|
|
2884
|
-
throw syntaxError(source, position, "Invalid character escape sequence: \\u".concat(invalidSequence, "."));
|
|
2885
|
-
}
|
|
3108
|
+
return '[' + items.join(', ') + ']';
|
|
3109
|
+
}
|
|
2886
3110
|
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
3111
|
+
function getObjectTag(object) {
|
|
3112
|
+
const tag = Object.prototype.toString
|
|
3113
|
+
.call(object)
|
|
3114
|
+
.replace(/^\[object /, '')
|
|
3115
|
+
.replace(/]$/, '');
|
|
2891
3116
|
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
}
|
|
3117
|
+
if (tag === 'Object' && typeof object.constructor === 'function') {
|
|
3118
|
+
const name = object.constructor.name;
|
|
2895
3119
|
|
|
2896
|
-
|
|
2897
|
-
|
|
3120
|
+
if (typeof name === 'string' && name !== '') {
|
|
3121
|
+
return name;
|
|
2898
3122
|
}
|
|
2899
3123
|
}
|
|
2900
3124
|
|
|
2901
|
-
|
|
3125
|
+
return tag;
|
|
2902
3126
|
}
|
|
3127
|
+
|
|
2903
3128
|
/**
|
|
2904
|
-
*
|
|
2905
|
-
*
|
|
2906
|
-
*
|
|
3129
|
+
* A replacement for instanceof which includes an error warning when multi-realm
|
|
3130
|
+
* constructors are detected.
|
|
3131
|
+
* See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
|
|
3132
|
+
* See: https://webpack.js.org/guides/production/
|
|
2907
3133
|
*/
|
|
2908
3134
|
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
var rawValue = '';
|
|
2916
|
-
|
|
2917
|
-
while (position < body.length && !isNaN(code = body.charCodeAt(position))) {
|
|
2918
|
-
// Closing Triple-Quote (""")
|
|
2919
|
-
if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
|
|
2920
|
-
rawValue += body.slice(chunkStart, position);
|
|
2921
|
-
return new Token(TokenKind.BLOCK_STRING, start, position + 3, line, col, prev, dedentBlockStringValue(rawValue));
|
|
2922
|
-
} // SourceCharacter
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {
|
|
2926
|
-
throw syntaxError(source, position, "Invalid character within String: ".concat(printCharCode(code), "."));
|
|
2927
|
-
}
|
|
2928
|
-
|
|
2929
|
-
if (code === 10) {
|
|
2930
|
-
// new line
|
|
2931
|
-
++position;
|
|
2932
|
-
++lexer.line;
|
|
2933
|
-
lexer.lineStart = position;
|
|
2934
|
-
} else if (code === 13) {
|
|
2935
|
-
// carriage return
|
|
2936
|
-
if (body.charCodeAt(position + 1) === 10) {
|
|
2937
|
-
position += 2;
|
|
2938
|
-
} else {
|
|
2939
|
-
++position;
|
|
3135
|
+
const instanceOf =
|
|
3136
|
+
/* c8 ignore next 5 */
|
|
3137
|
+
// FIXME: https://github.com/graphql/graphql-js/issues/2317
|
|
3138
|
+
process.env.NODE_ENV === 'production'
|
|
3139
|
+
? function instanceOf(value, constructor) {
|
|
3140
|
+
return value instanceof constructor;
|
|
2940
3141
|
}
|
|
3142
|
+
: function instanceOf(value, constructor) {
|
|
3143
|
+
if (value instanceof constructor) {
|
|
3144
|
+
return true;
|
|
3145
|
+
}
|
|
2941
3146
|
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
3147
|
+
if (typeof value === 'object' && value !== null) {
|
|
3148
|
+
var _value$constructor;
|
|
3149
|
+
|
|
3150
|
+
// Prefer Symbol.toStringTag since it is immune to minification.
|
|
3151
|
+
const className = constructor.prototype[Symbol.toStringTag];
|
|
3152
|
+
const valueClassName = // We still need to support constructor's name to detect conflicts with older versions of this library.
|
|
3153
|
+
Symbol.toStringTag in value // @ts-expect-error TS bug see, https://github.com/microsoft/TypeScript/issues/38009
|
|
3154
|
+
? value[Symbol.toStringTag]
|
|
3155
|
+
: (_value$constructor = value.constructor) === null ||
|
|
3156
|
+
_value$constructor === void 0
|
|
3157
|
+
? void 0
|
|
3158
|
+
: _value$constructor.name;
|
|
3159
|
+
|
|
3160
|
+
if (className === valueClassName) {
|
|
3161
|
+
const stringifiedValue = inspect(value);
|
|
3162
|
+
throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm.
|
|
3163
|
+
|
|
3164
|
+
Ensure that there is only one instance of "graphql" in the node_modules
|
|
3165
|
+
directory. If different versions of "graphql" are the dependencies of other
|
|
3166
|
+
relied on modules, use "resolutions" to ensure only one version is installed.
|
|
3167
|
+
|
|
3168
|
+
https://yarnpkg.com/en/docs/selective-version-resolutions
|
|
3169
|
+
|
|
3170
|
+
Duplicate "graphql" modules cannot be used at the same time since different
|
|
3171
|
+
versions may have different capabilities and behavior. The data from one
|
|
3172
|
+
version used in the function from another could produce confusing and
|
|
3173
|
+
spurious results.`);
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
2966
3176
|
|
|
3177
|
+
return false;
|
|
3178
|
+
};
|
|
2967
3179
|
|
|
2968
|
-
function uniCharCode(a, b, c, d) {
|
|
2969
|
-
return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d);
|
|
2970
|
-
}
|
|
2971
3180
|
/**
|
|
2972
|
-
*
|
|
2973
|
-
*
|
|
2974
|
-
*
|
|
2975
|
-
*
|
|
2976
|
-
*
|
|
2977
|
-
* Returns -1 on error.
|
|
3181
|
+
* A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
|
|
3182
|
+
* optional, but they are useful for clients who store GraphQL documents in source files.
|
|
3183
|
+
* For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
|
|
3184
|
+
* be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
|
|
3185
|
+
* The `line` and `column` properties in `locationOffset` are 1-indexed.
|
|
2978
3186
|
*/
|
|
3187
|
+
class Source {
|
|
3188
|
+
constructor(
|
|
3189
|
+
body,
|
|
3190
|
+
name = 'GraphQL request',
|
|
3191
|
+
locationOffset = {
|
|
3192
|
+
line: 1,
|
|
3193
|
+
column: 1,
|
|
3194
|
+
},
|
|
3195
|
+
) {
|
|
3196
|
+
typeof body === 'string' ||
|
|
3197
|
+
devAssert(false, `Body must be a string. Received: ${inspect(body)}.`);
|
|
3198
|
+
this.body = body;
|
|
3199
|
+
this.name = name;
|
|
3200
|
+
this.locationOffset = locationOffset;
|
|
3201
|
+
this.locationOffset.line > 0 ||
|
|
3202
|
+
devAssert(
|
|
3203
|
+
false,
|
|
3204
|
+
'line in locationOffset is 1-indexed and must be positive.',
|
|
3205
|
+
);
|
|
3206
|
+
this.locationOffset.column > 0 ||
|
|
3207
|
+
devAssert(
|
|
3208
|
+
false,
|
|
3209
|
+
'column in locationOffset is 1-indexed and must be positive.',
|
|
3210
|
+
);
|
|
3211
|
+
}
|
|
2979
3212
|
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
: a >= 65 && a <= 70 ? a - 55 // A-F
|
|
2984
|
-
: a >= 97 && a <= 102 ? a - 87 // a-f
|
|
2985
|
-
: -1;
|
|
3213
|
+
get [Symbol.toStringTag]() {
|
|
3214
|
+
return 'Source';
|
|
3215
|
+
}
|
|
2986
3216
|
}
|
|
2987
3217
|
/**
|
|
2988
|
-
*
|
|
3218
|
+
* Test if the given value is a Source object.
|
|
2989
3219
|
*
|
|
2990
|
-
*
|
|
3220
|
+
* @internal
|
|
2991
3221
|
*/
|
|
2992
3222
|
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
var body = source.body;
|
|
2996
|
-
var bodyLength = body.length;
|
|
2997
|
-
var position = start + 1;
|
|
2998
|
-
var code = 0;
|
|
2999
|
-
|
|
3000
|
-
while (position !== bodyLength && !isNaN(code = body.charCodeAt(position)) && (code === 95 || // _
|
|
3001
|
-
code >= 48 && code <= 57 || // 0-9
|
|
3002
|
-
code >= 65 && code <= 90 || // A-Z
|
|
3003
|
-
code >= 97 && code <= 122) // a-z
|
|
3004
|
-
) {
|
|
3005
|
-
++position;
|
|
3006
|
-
}
|
|
3007
|
-
|
|
3008
|
-
return new Token(TokenKind.NAME, start, position, line, col, prev, body.slice(start, position));
|
|
3009
|
-
} // _ A-Z a-z
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
function isNameStart(code) {
|
|
3013
|
-
return code === 95 || code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
3223
|
+
function isSource(source) {
|
|
3224
|
+
return instanceOf(source, Source);
|
|
3014
3225
|
}
|
|
3015
3226
|
|
|
3016
3227
|
/**
|
|
@@ -3022,7 +3233,7 @@ function isNameStart(code) {
|
|
|
3022
3233
|
* Throws GraphQLError if a syntax error is encountered.
|
|
3023
3234
|
*/
|
|
3024
3235
|
function parse$1(source, options) {
|
|
3025
|
-
|
|
3236
|
+
const parser = new Parser(source, options);
|
|
3026
3237
|
return parser.parseDocument();
|
|
3027
3238
|
}
|
|
3028
3239
|
/**
|
|
@@ -3037,9 +3248,9 @@ function parse$1(source, options) {
|
|
|
3037
3248
|
* @internal
|
|
3038
3249
|
*/
|
|
3039
3250
|
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3251
|
+
class Parser {
|
|
3252
|
+
constructor(source, options) {
|
|
3253
|
+
const sourceObj = isSource(source) ? source : new Source(source);
|
|
3043
3254
|
this._lexer = new Lexer(sourceObj);
|
|
3044
3255
|
this._options = options;
|
|
3045
3256
|
}
|
|
@@ -3047,30 +3258,27 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3047
3258
|
* Converts a name lex token into a name parse node.
|
|
3048
3259
|
*/
|
|
3049
3260
|
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
_proto.parseName = function parseName() {
|
|
3054
|
-
var token = this.expectToken(TokenKind.NAME);
|
|
3055
|
-
return {
|
|
3261
|
+
parseName() {
|
|
3262
|
+
const token = this.expectToken(TokenKind.NAME);
|
|
3263
|
+
return this.node(token, {
|
|
3056
3264
|
kind: Kind.NAME,
|
|
3057
3265
|
value: token.value,
|
|
3058
|
-
|
|
3059
|
-
};
|
|
3266
|
+
});
|
|
3060
3267
|
} // Implements the parsing rules in the Document section.
|
|
3061
3268
|
|
|
3062
3269
|
/**
|
|
3063
3270
|
* Document : Definition+
|
|
3064
3271
|
*/
|
|
3065
|
-
;
|
|
3066
3272
|
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
return {
|
|
3273
|
+
parseDocument() {
|
|
3274
|
+
return this.node(this._lexer.token, {
|
|
3070
3275
|
kind: Kind.DOCUMENT,
|
|
3071
|
-
definitions: this.many(
|
|
3072
|
-
|
|
3073
|
-
|
|
3276
|
+
definitions: this.many(
|
|
3277
|
+
TokenKind.SOF,
|
|
3278
|
+
this.parseDefinition,
|
|
3279
|
+
TokenKind.EOF,
|
|
3280
|
+
),
|
|
3281
|
+
});
|
|
3074
3282
|
}
|
|
3075
3283
|
/**
|
|
3076
3284
|
* Definition :
|
|
@@ -3081,40 +3289,81 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3081
3289
|
* ExecutableDefinition :
|
|
3082
3290
|
* - OperationDefinition
|
|
3083
3291
|
* - FragmentDefinition
|
|
3292
|
+
*
|
|
3293
|
+
* TypeSystemDefinition :
|
|
3294
|
+
* - SchemaDefinition
|
|
3295
|
+
* - TypeDefinition
|
|
3296
|
+
* - DirectiveDefinition
|
|
3297
|
+
*
|
|
3298
|
+
* TypeDefinition :
|
|
3299
|
+
* - ScalarTypeDefinition
|
|
3300
|
+
* - ObjectTypeDefinition
|
|
3301
|
+
* - InterfaceTypeDefinition
|
|
3302
|
+
* - UnionTypeDefinition
|
|
3303
|
+
* - EnumTypeDefinition
|
|
3304
|
+
* - InputObjectTypeDefinition
|
|
3084
3305
|
*/
|
|
3085
|
-
;
|
|
3086
3306
|
|
|
3087
|
-
|
|
3088
|
-
if (this.peek(TokenKind.
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
case 'mutation':
|
|
3092
|
-
case 'subscription':
|
|
3093
|
-
return this.parseOperationDefinition();
|
|
3307
|
+
parseDefinition() {
|
|
3308
|
+
if (this.peek(TokenKind.BRACE_L)) {
|
|
3309
|
+
return this.parseOperationDefinition();
|
|
3310
|
+
} // Many definitions begin with a description and require a lookahead.
|
|
3094
3311
|
|
|
3095
|
-
|
|
3096
|
-
|
|
3312
|
+
const hasDescription = this.peekDescription();
|
|
3313
|
+
const keywordToken = hasDescription
|
|
3314
|
+
? this._lexer.lookahead()
|
|
3315
|
+
: this._lexer.token;
|
|
3097
3316
|
|
|
3317
|
+
if (keywordToken.kind === TokenKind.NAME) {
|
|
3318
|
+
switch (keywordToken.value) {
|
|
3098
3319
|
case 'schema':
|
|
3320
|
+
return this.parseSchemaDefinition();
|
|
3321
|
+
|
|
3099
3322
|
case 'scalar':
|
|
3323
|
+
return this.parseScalarTypeDefinition();
|
|
3324
|
+
|
|
3100
3325
|
case 'type':
|
|
3326
|
+
return this.parseObjectTypeDefinition();
|
|
3327
|
+
|
|
3101
3328
|
case 'interface':
|
|
3329
|
+
return this.parseInterfaceTypeDefinition();
|
|
3330
|
+
|
|
3102
3331
|
case 'union':
|
|
3332
|
+
return this.parseUnionTypeDefinition();
|
|
3333
|
+
|
|
3103
3334
|
case 'enum':
|
|
3335
|
+
return this.parseEnumTypeDefinition();
|
|
3336
|
+
|
|
3104
3337
|
case 'input':
|
|
3338
|
+
return this.parseInputObjectTypeDefinition();
|
|
3339
|
+
|
|
3105
3340
|
case 'directive':
|
|
3106
|
-
return this.
|
|
3341
|
+
return this.parseDirectiveDefinition();
|
|
3342
|
+
}
|
|
3343
|
+
|
|
3344
|
+
if (hasDescription) {
|
|
3345
|
+
throw syntaxError(
|
|
3346
|
+
this._lexer.source,
|
|
3347
|
+
this._lexer.token.start,
|
|
3348
|
+
'Unexpected description, descriptions are supported only on type definitions.',
|
|
3349
|
+
);
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
switch (keywordToken.value) {
|
|
3353
|
+
case 'query':
|
|
3354
|
+
case 'mutation':
|
|
3355
|
+
case 'subscription':
|
|
3356
|
+
return this.parseOperationDefinition();
|
|
3357
|
+
|
|
3358
|
+
case 'fragment':
|
|
3359
|
+
return this.parseFragmentDefinition();
|
|
3107
3360
|
|
|
3108
3361
|
case 'extend':
|
|
3109
3362
|
return this.parseTypeSystemExtension();
|
|
3110
3363
|
}
|
|
3111
|
-
} else if (this.peek(TokenKind.BRACE_L)) {
|
|
3112
|
-
return this.parseOperationDefinition();
|
|
3113
|
-
} else if (this.peekDescription()) {
|
|
3114
|
-
return this.parseTypeSystemDefinition();
|
|
3115
3364
|
}
|
|
3116
3365
|
|
|
3117
|
-
throw this.unexpected();
|
|
3366
|
+
throw this.unexpected(keywordToken);
|
|
3118
3367
|
} // Implements the parsing rules in the Operations section.
|
|
3119
3368
|
|
|
3120
3369
|
/**
|
|
@@ -3122,57 +3371,53 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3122
3371
|
* - SelectionSet
|
|
3123
3372
|
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
|
|
3124
3373
|
*/
|
|
3125
|
-
;
|
|
3126
3374
|
|
|
3127
|
-
|
|
3128
|
-
|
|
3375
|
+
parseOperationDefinition() {
|
|
3376
|
+
const start = this._lexer.token;
|
|
3129
3377
|
|
|
3130
3378
|
if (this.peek(TokenKind.BRACE_L)) {
|
|
3131
|
-
return {
|
|
3379
|
+
return this.node(start, {
|
|
3132
3380
|
kind: Kind.OPERATION_DEFINITION,
|
|
3133
|
-
operation:
|
|
3381
|
+
operation: OperationTypeNode.QUERY,
|
|
3134
3382
|
name: undefined,
|
|
3135
3383
|
variableDefinitions: [],
|
|
3136
3384
|
directives: [],
|
|
3137
3385
|
selectionSet: this.parseSelectionSet(),
|
|
3138
|
-
|
|
3139
|
-
};
|
|
3386
|
+
});
|
|
3140
3387
|
}
|
|
3141
3388
|
|
|
3142
|
-
|
|
3143
|
-
|
|
3389
|
+
const operation = this.parseOperationType();
|
|
3390
|
+
let name;
|
|
3144
3391
|
|
|
3145
3392
|
if (this.peek(TokenKind.NAME)) {
|
|
3146
3393
|
name = this.parseName();
|
|
3147
3394
|
}
|
|
3148
3395
|
|
|
3149
|
-
return {
|
|
3396
|
+
return this.node(start, {
|
|
3150
3397
|
kind: Kind.OPERATION_DEFINITION,
|
|
3151
|
-
operation
|
|
3152
|
-
name
|
|
3398
|
+
operation,
|
|
3399
|
+
name,
|
|
3153
3400
|
variableDefinitions: this.parseVariableDefinitions(),
|
|
3154
3401
|
directives: this.parseDirectives(false),
|
|
3155
3402
|
selectionSet: this.parseSelectionSet(),
|
|
3156
|
-
|
|
3157
|
-
};
|
|
3403
|
+
});
|
|
3158
3404
|
}
|
|
3159
3405
|
/**
|
|
3160
3406
|
* OperationType : one of query mutation subscription
|
|
3161
3407
|
*/
|
|
3162
|
-
;
|
|
3163
3408
|
|
|
3164
|
-
|
|
3165
|
-
|
|
3409
|
+
parseOperationType() {
|
|
3410
|
+
const operationToken = this.expectToken(TokenKind.NAME);
|
|
3166
3411
|
|
|
3167
3412
|
switch (operationToken.value) {
|
|
3168
3413
|
case 'query':
|
|
3169
|
-
return
|
|
3414
|
+
return OperationTypeNode.QUERY;
|
|
3170
3415
|
|
|
3171
3416
|
case 'mutation':
|
|
3172
|
-
return
|
|
3417
|
+
return OperationTypeNode.MUTATION;
|
|
3173
3418
|
|
|
3174
3419
|
case 'subscription':
|
|
3175
|
-
return
|
|
3420
|
+
return OperationTypeNode.SUBSCRIPTION;
|
|
3176
3421
|
}
|
|
3177
3422
|
|
|
3178
3423
|
throw this.unexpected(operationToken);
|
|
@@ -3180,53 +3425,56 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3180
3425
|
/**
|
|
3181
3426
|
* VariableDefinitions : ( VariableDefinition+ )
|
|
3182
3427
|
*/
|
|
3183
|
-
;
|
|
3184
3428
|
|
|
3185
|
-
|
|
3186
|
-
return this.optionalMany(
|
|
3429
|
+
parseVariableDefinitions() {
|
|
3430
|
+
return this.optionalMany(
|
|
3431
|
+
TokenKind.PAREN_L,
|
|
3432
|
+
this.parseVariableDefinition,
|
|
3433
|
+
TokenKind.PAREN_R,
|
|
3434
|
+
);
|
|
3187
3435
|
}
|
|
3188
3436
|
/**
|
|
3189
3437
|
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
|
|
3190
3438
|
*/
|
|
3191
|
-
;
|
|
3192
3439
|
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
return {
|
|
3440
|
+
parseVariableDefinition() {
|
|
3441
|
+
return this.node(this._lexer.token, {
|
|
3196
3442
|
kind: Kind.VARIABLE_DEFINITION,
|
|
3197
3443
|
variable: this.parseVariable(),
|
|
3198
3444
|
type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),
|
|
3199
|
-
defaultValue: this.expectOptionalToken(TokenKind.EQUALS)
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3445
|
+
defaultValue: this.expectOptionalToken(TokenKind.EQUALS)
|
|
3446
|
+
? this.parseConstValueLiteral()
|
|
3447
|
+
: undefined,
|
|
3448
|
+
directives: this.parseConstDirectives(),
|
|
3449
|
+
});
|
|
3203
3450
|
}
|
|
3204
3451
|
/**
|
|
3205
3452
|
* Variable : $ Name
|
|
3206
3453
|
*/
|
|
3207
|
-
;
|
|
3208
3454
|
|
|
3209
|
-
|
|
3210
|
-
|
|
3455
|
+
parseVariable() {
|
|
3456
|
+
const start = this._lexer.token;
|
|
3211
3457
|
this.expectToken(TokenKind.DOLLAR);
|
|
3212
|
-
return {
|
|
3458
|
+
return this.node(start, {
|
|
3213
3459
|
kind: Kind.VARIABLE,
|
|
3214
3460
|
name: this.parseName(),
|
|
3215
|
-
|
|
3216
|
-
};
|
|
3461
|
+
});
|
|
3217
3462
|
}
|
|
3218
3463
|
/**
|
|
3464
|
+
* ```
|
|
3219
3465
|
* SelectionSet : { Selection+ }
|
|
3466
|
+
* ```
|
|
3220
3467
|
*/
|
|
3221
|
-
;
|
|
3222
3468
|
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
return {
|
|
3469
|
+
parseSelectionSet() {
|
|
3470
|
+
return this.node(this._lexer.token, {
|
|
3226
3471
|
kind: Kind.SELECTION_SET,
|
|
3227
|
-
selections: this.many(
|
|
3228
|
-
|
|
3229
|
-
|
|
3472
|
+
selections: this.many(
|
|
3473
|
+
TokenKind.BRACE_L,
|
|
3474
|
+
this.parseSelection,
|
|
3475
|
+
TokenKind.BRACE_R,
|
|
3476
|
+
),
|
|
3477
|
+
});
|
|
3230
3478
|
}
|
|
3231
3479
|
/**
|
|
3232
3480
|
* Selection :
|
|
@@ -3234,23 +3482,23 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3234
3482
|
* - FragmentSpread
|
|
3235
3483
|
* - InlineFragment
|
|
3236
3484
|
*/
|
|
3237
|
-
;
|
|
3238
3485
|
|
|
3239
|
-
|
|
3240
|
-
return this.peek(TokenKind.SPREAD)
|
|
3486
|
+
parseSelection() {
|
|
3487
|
+
return this.peek(TokenKind.SPREAD)
|
|
3488
|
+
? this.parseFragment()
|
|
3489
|
+
: this.parseField();
|
|
3241
3490
|
}
|
|
3242
3491
|
/**
|
|
3243
3492
|
* Field : Alias? Name Arguments? Directives? SelectionSet?
|
|
3244
3493
|
*
|
|
3245
3494
|
* Alias : Name :
|
|
3246
3495
|
*/
|
|
3247
|
-
;
|
|
3248
3496
|
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3497
|
+
parseField() {
|
|
3498
|
+
const start = this._lexer.token;
|
|
3499
|
+
const nameOrAlias = this.parseName();
|
|
3500
|
+
let alias;
|
|
3501
|
+
let name;
|
|
3254
3502
|
|
|
3255
3503
|
if (this.expectOptionalToken(TokenKind.COLON)) {
|
|
3256
3504
|
alias = nameOrAlias;
|
|
@@ -3259,50 +3507,42 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3259
3507
|
name = nameOrAlias;
|
|
3260
3508
|
}
|
|
3261
3509
|
|
|
3262
|
-
return {
|
|
3510
|
+
return this.node(start, {
|
|
3263
3511
|
kind: Kind.FIELD,
|
|
3264
|
-
alias
|
|
3265
|
-
name
|
|
3512
|
+
alias,
|
|
3513
|
+
name,
|
|
3266
3514
|
arguments: this.parseArguments(false),
|
|
3267
3515
|
directives: this.parseDirectives(false),
|
|
3268
|
-
selectionSet: this.peek(TokenKind.BRACE_L)
|
|
3269
|
-
|
|
3270
|
-
|
|
3516
|
+
selectionSet: this.peek(TokenKind.BRACE_L)
|
|
3517
|
+
? this.parseSelectionSet()
|
|
3518
|
+
: undefined,
|
|
3519
|
+
});
|
|
3271
3520
|
}
|
|
3272
3521
|
/**
|
|
3273
3522
|
* Arguments[Const] : ( Argument[?Const]+ )
|
|
3274
3523
|
*/
|
|
3275
|
-
;
|
|
3276
3524
|
|
|
3277
|
-
|
|
3278
|
-
|
|
3525
|
+
parseArguments(isConst) {
|
|
3526
|
+
const item = isConst ? this.parseConstArgument : this.parseArgument;
|
|
3279
3527
|
return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);
|
|
3280
3528
|
}
|
|
3281
3529
|
/**
|
|
3282
3530
|
* Argument[Const] : Name : Value[?Const]
|
|
3283
3531
|
*/
|
|
3284
|
-
;
|
|
3285
3532
|
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3533
|
+
parseArgument(isConst = false) {
|
|
3534
|
+
const start = this._lexer.token;
|
|
3535
|
+
const name = this.parseName();
|
|
3289
3536
|
this.expectToken(TokenKind.COLON);
|
|
3290
|
-
return {
|
|
3537
|
+
return this.node(start, {
|
|
3291
3538
|
kind: Kind.ARGUMENT,
|
|
3292
|
-
name
|
|
3293
|
-
value: this.parseValueLiteral(
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
};
|
|
3539
|
+
name,
|
|
3540
|
+
value: this.parseValueLiteral(isConst),
|
|
3541
|
+
});
|
|
3542
|
+
}
|
|
3297
3543
|
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
return {
|
|
3301
|
-
kind: Kind.ARGUMENT,
|
|
3302
|
-
name: this.parseName(),
|
|
3303
|
-
value: (this.expectToken(TokenKind.COLON), this.parseValueLiteral(true)),
|
|
3304
|
-
loc: this.loc(start)
|
|
3305
|
-
};
|
|
3544
|
+
parseConstArgument() {
|
|
3545
|
+
return this.parseArgument(true);
|
|
3306
3546
|
} // Implements the parsing rules in the Fragments section.
|
|
3307
3547
|
|
|
3308
3548
|
/**
|
|
@@ -3312,29 +3552,26 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3312
3552
|
*
|
|
3313
3553
|
* InlineFragment : ... TypeCondition? Directives? SelectionSet
|
|
3314
3554
|
*/
|
|
3315
|
-
;
|
|
3316
3555
|
|
|
3317
|
-
|
|
3318
|
-
|
|
3556
|
+
parseFragment() {
|
|
3557
|
+
const start = this._lexer.token;
|
|
3319
3558
|
this.expectToken(TokenKind.SPREAD);
|
|
3320
|
-
|
|
3559
|
+
const hasTypeCondition = this.expectOptionalKeyword('on');
|
|
3321
3560
|
|
|
3322
3561
|
if (!hasTypeCondition && this.peek(TokenKind.NAME)) {
|
|
3323
|
-
return {
|
|
3562
|
+
return this.node(start, {
|
|
3324
3563
|
kind: Kind.FRAGMENT_SPREAD,
|
|
3325
3564
|
name: this.parseFragmentName(),
|
|
3326
3565
|
directives: this.parseDirectives(false),
|
|
3327
|
-
|
|
3328
|
-
};
|
|
3566
|
+
});
|
|
3329
3567
|
}
|
|
3330
3568
|
|
|
3331
|
-
return {
|
|
3569
|
+
return this.node(start, {
|
|
3332
3570
|
kind: Kind.INLINE_FRAGMENT,
|
|
3333
3571
|
typeCondition: hasTypeCondition ? this.parseNamedType() : undefined,
|
|
3334
3572
|
directives: this.parseDirectives(false),
|
|
3335
3573
|
selectionSet: this.parseSelectionSet(),
|
|
3336
|
-
|
|
3337
|
-
};
|
|
3574
|
+
});
|
|
3338
3575
|
}
|
|
3339
3576
|
/**
|
|
3340
3577
|
* FragmentDefinition :
|
|
@@ -3342,43 +3579,43 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3342
3579
|
*
|
|
3343
3580
|
* TypeCondition : NamedType
|
|
3344
3581
|
*/
|
|
3345
|
-
;
|
|
3346
3582
|
|
|
3347
|
-
|
|
3583
|
+
parseFragmentDefinition() {
|
|
3348
3584
|
var _this$_options;
|
|
3349
3585
|
|
|
3350
|
-
|
|
3351
|
-
this.expectKeyword('fragment'); //
|
|
3586
|
+
const start = this._lexer.token;
|
|
3587
|
+
this.expectKeyword('fragment'); // Legacy support for defining variables within fragments changes
|
|
3352
3588
|
// the grammar of FragmentDefinition:
|
|
3353
3589
|
// - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
|
|
3354
3590
|
|
|
3355
|
-
if (
|
|
3356
|
-
|
|
3591
|
+
if (
|
|
3592
|
+
((_this$_options = this._options) === null || _this$_options === void 0
|
|
3593
|
+
? void 0
|
|
3594
|
+
: _this$_options.allowLegacyFragmentVariables) === true
|
|
3595
|
+
) {
|
|
3596
|
+
return this.node(start, {
|
|
3357
3597
|
kind: Kind.FRAGMENT_DEFINITION,
|
|
3358
3598
|
name: this.parseFragmentName(),
|
|
3359
3599
|
variableDefinitions: this.parseVariableDefinitions(),
|
|
3360
3600
|
typeCondition: (this.expectKeyword('on'), this.parseNamedType()),
|
|
3361
3601
|
directives: this.parseDirectives(false),
|
|
3362
3602
|
selectionSet: this.parseSelectionSet(),
|
|
3363
|
-
|
|
3364
|
-
};
|
|
3603
|
+
});
|
|
3365
3604
|
}
|
|
3366
3605
|
|
|
3367
|
-
return {
|
|
3606
|
+
return this.node(start, {
|
|
3368
3607
|
kind: Kind.FRAGMENT_DEFINITION,
|
|
3369
3608
|
name: this.parseFragmentName(),
|
|
3370
3609
|
typeCondition: (this.expectKeyword('on'), this.parseNamedType()),
|
|
3371
3610
|
directives: this.parseDirectives(false),
|
|
3372
3611
|
selectionSet: this.parseSelectionSet(),
|
|
3373
|
-
|
|
3374
|
-
};
|
|
3612
|
+
});
|
|
3375
3613
|
}
|
|
3376
3614
|
/**
|
|
3377
3615
|
* FragmentName : Name but not `on`
|
|
3378
3616
|
*/
|
|
3379
|
-
;
|
|
3380
3617
|
|
|
3381
|
-
|
|
3618
|
+
parseFragmentName() {
|
|
3382
3619
|
if (this._lexer.token.value === 'on') {
|
|
3383
3620
|
throw this.unexpected();
|
|
3384
3621
|
}
|
|
@@ -3404,10 +3641,9 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3404
3641
|
*
|
|
3405
3642
|
* EnumValue : Name but not `true`, `false` or `null`
|
|
3406
3643
|
*/
|
|
3407
|
-
;
|
|
3408
3644
|
|
|
3409
|
-
|
|
3410
|
-
|
|
3645
|
+
parseValueLiteral(isConst) {
|
|
3646
|
+
const token = this._lexer.token;
|
|
3411
3647
|
|
|
3412
3648
|
switch (token.kind) {
|
|
3413
3649
|
case TokenKind.BRACKET_L:
|
|
@@ -3419,20 +3655,18 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3419
3655
|
case TokenKind.INT:
|
|
3420
3656
|
this._lexer.advance();
|
|
3421
3657
|
|
|
3422
|
-
return {
|
|
3658
|
+
return this.node(token, {
|
|
3423
3659
|
kind: Kind.INT,
|
|
3424
3660
|
value: token.value,
|
|
3425
|
-
|
|
3426
|
-
};
|
|
3661
|
+
});
|
|
3427
3662
|
|
|
3428
3663
|
case TokenKind.FLOAT:
|
|
3429
3664
|
this._lexer.advance();
|
|
3430
3665
|
|
|
3431
|
-
return {
|
|
3666
|
+
return this.node(token, {
|
|
3432
3667
|
kind: Kind.FLOAT,
|
|
3433
3668
|
value: token.value,
|
|
3434
|
-
|
|
3435
|
-
};
|
|
3669
|
+
});
|
|
3436
3670
|
|
|
3437
3671
|
case TokenKind.STRING:
|
|
3438
3672
|
case TokenKind.BLOCK_STRING:
|
|
@@ -3443,124 +3677,118 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3443
3677
|
|
|
3444
3678
|
switch (token.value) {
|
|
3445
3679
|
case 'true':
|
|
3446
|
-
return {
|
|
3680
|
+
return this.node(token, {
|
|
3447
3681
|
kind: Kind.BOOLEAN,
|
|
3448
3682
|
value: true,
|
|
3449
|
-
|
|
3450
|
-
};
|
|
3683
|
+
});
|
|
3451
3684
|
|
|
3452
3685
|
case 'false':
|
|
3453
|
-
return {
|
|
3686
|
+
return this.node(token, {
|
|
3454
3687
|
kind: Kind.BOOLEAN,
|
|
3455
3688
|
value: false,
|
|
3456
|
-
|
|
3457
|
-
};
|
|
3689
|
+
});
|
|
3458
3690
|
|
|
3459
3691
|
case 'null':
|
|
3460
|
-
return {
|
|
3692
|
+
return this.node(token, {
|
|
3461
3693
|
kind: Kind.NULL,
|
|
3462
|
-
|
|
3463
|
-
};
|
|
3694
|
+
});
|
|
3464
3695
|
|
|
3465
3696
|
default:
|
|
3466
|
-
return {
|
|
3697
|
+
return this.node(token, {
|
|
3467
3698
|
kind: Kind.ENUM,
|
|
3468
3699
|
value: token.value,
|
|
3469
|
-
|
|
3470
|
-
};
|
|
3700
|
+
});
|
|
3471
3701
|
}
|
|
3472
3702
|
|
|
3473
3703
|
case TokenKind.DOLLAR:
|
|
3474
|
-
if (
|
|
3475
|
-
|
|
3704
|
+
if (isConst) {
|
|
3705
|
+
this.expectToken(TokenKind.DOLLAR);
|
|
3706
|
+
|
|
3707
|
+
if (this._lexer.token.kind === TokenKind.NAME) {
|
|
3708
|
+
const varName = this._lexer.token.value;
|
|
3709
|
+
throw syntaxError(
|
|
3710
|
+
this._lexer.source,
|
|
3711
|
+
token.start,
|
|
3712
|
+
`Unexpected variable "$${varName}" in constant value.`,
|
|
3713
|
+
);
|
|
3714
|
+
} else {
|
|
3715
|
+
throw this.unexpected(token);
|
|
3716
|
+
}
|
|
3476
3717
|
}
|
|
3477
3718
|
|
|
3478
|
-
|
|
3719
|
+
return this.parseVariable();
|
|
3720
|
+
|
|
3721
|
+
default:
|
|
3722
|
+
throw this.unexpected();
|
|
3479
3723
|
}
|
|
3724
|
+
}
|
|
3480
3725
|
|
|
3481
|
-
|
|
3482
|
-
|
|
3726
|
+
parseConstValueLiteral() {
|
|
3727
|
+
return this.parseValueLiteral(true);
|
|
3728
|
+
}
|
|
3483
3729
|
|
|
3484
|
-
|
|
3485
|
-
|
|
3730
|
+
parseStringLiteral() {
|
|
3731
|
+
const token = this._lexer.token;
|
|
3486
3732
|
|
|
3487
3733
|
this._lexer.advance();
|
|
3488
3734
|
|
|
3489
|
-
return {
|
|
3735
|
+
return this.node(token, {
|
|
3490
3736
|
kind: Kind.STRING,
|
|
3491
3737
|
value: token.value,
|
|
3492
3738
|
block: token.kind === TokenKind.BLOCK_STRING,
|
|
3493
|
-
|
|
3494
|
-
};
|
|
3739
|
+
});
|
|
3495
3740
|
}
|
|
3496
3741
|
/**
|
|
3497
3742
|
* ListValue[Const] :
|
|
3498
3743
|
* - [ ]
|
|
3499
3744
|
* - [ Value[?Const]+ ]
|
|
3500
3745
|
*/
|
|
3501
|
-
;
|
|
3502
|
-
|
|
3503
|
-
_proto.parseList = function parseList(isConst) {
|
|
3504
|
-
var _this = this;
|
|
3505
3746
|
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
var item = function item() {
|
|
3509
|
-
return _this.parseValueLiteral(isConst);
|
|
3510
|
-
};
|
|
3747
|
+
parseList(isConst) {
|
|
3748
|
+
const item = () => this.parseValueLiteral(isConst);
|
|
3511
3749
|
|
|
3512
|
-
return {
|
|
3750
|
+
return this.node(this._lexer.token, {
|
|
3513
3751
|
kind: Kind.LIST,
|
|
3514
3752
|
values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R),
|
|
3515
|
-
|
|
3516
|
-
};
|
|
3753
|
+
});
|
|
3517
3754
|
}
|
|
3518
3755
|
/**
|
|
3756
|
+
* ```
|
|
3519
3757
|
* ObjectValue[Const] :
|
|
3520
3758
|
* - { }
|
|
3521
3759
|
* - { ObjectField[?Const]+ }
|
|
3760
|
+
* ```
|
|
3522
3761
|
*/
|
|
3523
|
-
;
|
|
3524
|
-
|
|
3525
|
-
_proto.parseObject = function parseObject(isConst) {
|
|
3526
|
-
var _this2 = this;
|
|
3527
3762
|
|
|
3528
|
-
|
|
3763
|
+
parseObject(isConst) {
|
|
3764
|
+
const item = () => this.parseObjectField(isConst);
|
|
3529
3765
|
|
|
3530
|
-
|
|
3531
|
-
return _this2.parseObjectField(isConst);
|
|
3532
|
-
};
|
|
3533
|
-
|
|
3534
|
-
return {
|
|
3766
|
+
return this.node(this._lexer.token, {
|
|
3535
3767
|
kind: Kind.OBJECT,
|
|
3536
3768
|
fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R),
|
|
3537
|
-
|
|
3538
|
-
};
|
|
3769
|
+
});
|
|
3539
3770
|
}
|
|
3540
3771
|
/**
|
|
3541
3772
|
* ObjectField[Const] : Name : Value[?Const]
|
|
3542
3773
|
*/
|
|
3543
|
-
;
|
|
3544
3774
|
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3775
|
+
parseObjectField(isConst) {
|
|
3776
|
+
const start = this._lexer.token;
|
|
3777
|
+
const name = this.parseName();
|
|
3548
3778
|
this.expectToken(TokenKind.COLON);
|
|
3549
|
-
return {
|
|
3779
|
+
return this.node(start, {
|
|
3550
3780
|
kind: Kind.OBJECT_FIELD,
|
|
3551
|
-
name
|
|
3781
|
+
name,
|
|
3552
3782
|
value: this.parseValueLiteral(isConst),
|
|
3553
|
-
|
|
3554
|
-
};
|
|
3783
|
+
});
|
|
3555
3784
|
} // Implements the parsing rules in the Directives section.
|
|
3556
3785
|
|
|
3557
3786
|
/**
|
|
3558
3787
|
* Directives[Const] : Directive[?Const]+
|
|
3559
3788
|
*/
|
|
3560
|
-
;
|
|
3561
3789
|
|
|
3562
|
-
|
|
3563
|
-
|
|
3790
|
+
parseDirectives(isConst) {
|
|
3791
|
+
const directives = [];
|
|
3564
3792
|
|
|
3565
3793
|
while (this.peek(TokenKind.AT)) {
|
|
3566
3794
|
directives.push(this.parseDirective(isConst));
|
|
@@ -3568,20 +3796,24 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3568
3796
|
|
|
3569
3797
|
return directives;
|
|
3570
3798
|
}
|
|
3799
|
+
|
|
3800
|
+
parseConstDirectives() {
|
|
3801
|
+
return this.parseDirectives(true);
|
|
3802
|
+
}
|
|
3571
3803
|
/**
|
|
3804
|
+
* ```
|
|
3572
3805
|
* Directive[Const] : @ Name Arguments[?Const]?
|
|
3806
|
+
* ```
|
|
3573
3807
|
*/
|
|
3574
|
-
;
|
|
3575
3808
|
|
|
3576
|
-
|
|
3577
|
-
|
|
3809
|
+
parseDirective(isConst) {
|
|
3810
|
+
const start = this._lexer.token;
|
|
3578
3811
|
this.expectToken(TokenKind.AT);
|
|
3579
|
-
return {
|
|
3812
|
+
return this.node(start, {
|
|
3580
3813
|
kind: Kind.DIRECTIVE,
|
|
3581
3814
|
name: this.parseName(),
|
|
3582
3815
|
arguments: this.parseArguments(isConst),
|
|
3583
|
-
|
|
3584
|
-
};
|
|
3816
|
+
});
|
|
3585
3817
|
} // Implements the parsing rules in the Types section.
|
|
3586
3818
|
|
|
3587
3819
|
/**
|
|
@@ -3590,30 +3822,27 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3590
3822
|
* - ListType
|
|
3591
3823
|
* - NonNullType
|
|
3592
3824
|
*/
|
|
3593
|
-
;
|
|
3594
3825
|
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3826
|
+
parseTypeReference() {
|
|
3827
|
+
const start = this._lexer.token;
|
|
3828
|
+
let type;
|
|
3598
3829
|
|
|
3599
3830
|
if (this.expectOptionalToken(TokenKind.BRACKET_L)) {
|
|
3600
|
-
|
|
3831
|
+
const innerType = this.parseTypeReference();
|
|
3601
3832
|
this.expectToken(TokenKind.BRACKET_R);
|
|
3602
|
-
type = {
|
|
3833
|
+
type = this.node(start, {
|
|
3603
3834
|
kind: Kind.LIST_TYPE,
|
|
3604
|
-
type:
|
|
3605
|
-
|
|
3606
|
-
};
|
|
3835
|
+
type: innerType,
|
|
3836
|
+
});
|
|
3607
3837
|
} else {
|
|
3608
3838
|
type = this.parseNamedType();
|
|
3609
3839
|
}
|
|
3610
3840
|
|
|
3611
3841
|
if (this.expectOptionalToken(TokenKind.BANG)) {
|
|
3612
|
-
return {
|
|
3842
|
+
return this.node(start, {
|
|
3613
3843
|
kind: Kind.NON_NULL_TYPE,
|
|
3614
|
-
type
|
|
3615
|
-
|
|
3616
|
-
};
|
|
3844
|
+
type,
|
|
3845
|
+
});
|
|
3617
3846
|
}
|
|
3618
3847
|
|
|
3619
3848
|
return type;
|
|
@@ -3621,404 +3850,343 @@ var Parser = /*#__PURE__*/function () {
|
|
|
3621
3850
|
/**
|
|
3622
3851
|
* NamedType : Name
|
|
3623
3852
|
*/
|
|
3624
|
-
;
|
|
3625
3853
|
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
return {
|
|
3854
|
+
parseNamedType() {
|
|
3855
|
+
return this.node(this._lexer.token, {
|
|
3629
3856
|
kind: Kind.NAMED_TYPE,
|
|
3630
3857
|
name: this.parseName(),
|
|
3631
|
-
|
|
3632
|
-
};
|
|
3858
|
+
});
|
|
3633
3859
|
} // Implements the parsing rules in the Type Definition section.
|
|
3634
3860
|
|
|
3635
|
-
|
|
3636
|
-
* TypeSystemDefinition :
|
|
3637
|
-
* - SchemaDefinition
|
|
3638
|
-
* - TypeDefinition
|
|
3639
|
-
* - DirectiveDefinition
|
|
3640
|
-
*
|
|
3641
|
-
* TypeDefinition :
|
|
3642
|
-
* - ScalarTypeDefinition
|
|
3643
|
-
* - ObjectTypeDefinition
|
|
3644
|
-
* - InterfaceTypeDefinition
|
|
3645
|
-
* - UnionTypeDefinition
|
|
3646
|
-
* - EnumTypeDefinition
|
|
3647
|
-
* - InputObjectTypeDefinition
|
|
3648
|
-
*/
|
|
3649
|
-
;
|
|
3650
|
-
|
|
3651
|
-
_proto.parseTypeSystemDefinition = function parseTypeSystemDefinition() {
|
|
3652
|
-
// Many definitions begin with a description and require a lookahead.
|
|
3653
|
-
var keywordToken = this.peekDescription() ? this._lexer.lookahead() : this._lexer.token;
|
|
3654
|
-
|
|
3655
|
-
if (keywordToken.kind === TokenKind.NAME) {
|
|
3656
|
-
switch (keywordToken.value) {
|
|
3657
|
-
case 'schema':
|
|
3658
|
-
return this.parseSchemaDefinition();
|
|
3659
|
-
|
|
3660
|
-
case 'scalar':
|
|
3661
|
-
return this.parseScalarTypeDefinition();
|
|
3662
|
-
|
|
3663
|
-
case 'type':
|
|
3664
|
-
return this.parseObjectTypeDefinition();
|
|
3665
|
-
|
|
3666
|
-
case 'interface':
|
|
3667
|
-
return this.parseInterfaceTypeDefinition();
|
|
3668
|
-
|
|
3669
|
-
case 'union':
|
|
3670
|
-
return this.parseUnionTypeDefinition();
|
|
3671
|
-
|
|
3672
|
-
case 'enum':
|
|
3673
|
-
return this.parseEnumTypeDefinition();
|
|
3674
|
-
|
|
3675
|
-
case 'input':
|
|
3676
|
-
return this.parseInputObjectTypeDefinition();
|
|
3677
|
-
|
|
3678
|
-
case 'directive':
|
|
3679
|
-
return this.parseDirectiveDefinition();
|
|
3680
|
-
}
|
|
3681
|
-
}
|
|
3682
|
-
|
|
3683
|
-
throw this.unexpected(keywordToken);
|
|
3684
|
-
};
|
|
3685
|
-
|
|
3686
|
-
_proto.peekDescription = function peekDescription() {
|
|
3861
|
+
peekDescription() {
|
|
3687
3862
|
return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);
|
|
3688
3863
|
}
|
|
3689
3864
|
/**
|
|
3690
3865
|
* Description : StringValue
|
|
3691
3866
|
*/
|
|
3692
|
-
;
|
|
3693
3867
|
|
|
3694
|
-
|
|
3868
|
+
parseDescription() {
|
|
3695
3869
|
if (this.peekDescription()) {
|
|
3696
3870
|
return this.parseStringLiteral();
|
|
3697
3871
|
}
|
|
3698
3872
|
}
|
|
3699
3873
|
/**
|
|
3874
|
+
* ```
|
|
3700
3875
|
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
|
|
3876
|
+
* ```
|
|
3701
3877
|
*/
|
|
3702
|
-
;
|
|
3703
3878
|
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3879
|
+
parseSchemaDefinition() {
|
|
3880
|
+
const start = this._lexer.token;
|
|
3881
|
+
const description = this.parseDescription();
|
|
3707
3882
|
this.expectKeyword('schema');
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3883
|
+
const directives = this.parseConstDirectives();
|
|
3884
|
+
const operationTypes = this.many(
|
|
3885
|
+
TokenKind.BRACE_L,
|
|
3886
|
+
this.parseOperationTypeDefinition,
|
|
3887
|
+
TokenKind.BRACE_R,
|
|
3888
|
+
);
|
|
3889
|
+
return this.node(start, {
|
|
3711
3890
|
kind: Kind.SCHEMA_DEFINITION,
|
|
3712
|
-
description
|
|
3713
|
-
directives
|
|
3714
|
-
operationTypes
|
|
3715
|
-
|
|
3716
|
-
};
|
|
3891
|
+
description,
|
|
3892
|
+
directives,
|
|
3893
|
+
operationTypes,
|
|
3894
|
+
});
|
|
3717
3895
|
}
|
|
3718
3896
|
/**
|
|
3719
3897
|
* OperationTypeDefinition : OperationType : NamedType
|
|
3720
3898
|
*/
|
|
3721
|
-
;
|
|
3722
3899
|
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3900
|
+
parseOperationTypeDefinition() {
|
|
3901
|
+
const start = this._lexer.token;
|
|
3902
|
+
const operation = this.parseOperationType();
|
|
3726
3903
|
this.expectToken(TokenKind.COLON);
|
|
3727
|
-
|
|
3728
|
-
return {
|
|
3904
|
+
const type = this.parseNamedType();
|
|
3905
|
+
return this.node(start, {
|
|
3729
3906
|
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
3730
|
-
operation
|
|
3731
|
-
type
|
|
3732
|
-
|
|
3733
|
-
};
|
|
3907
|
+
operation,
|
|
3908
|
+
type,
|
|
3909
|
+
});
|
|
3734
3910
|
}
|
|
3735
3911
|
/**
|
|
3736
3912
|
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
|
|
3737
3913
|
*/
|
|
3738
|
-
;
|
|
3739
3914
|
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3915
|
+
parseScalarTypeDefinition() {
|
|
3916
|
+
const start = this._lexer.token;
|
|
3917
|
+
const description = this.parseDescription();
|
|
3743
3918
|
this.expectKeyword('scalar');
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
return {
|
|
3919
|
+
const name = this.parseName();
|
|
3920
|
+
const directives = this.parseConstDirectives();
|
|
3921
|
+
return this.node(start, {
|
|
3747
3922
|
kind: Kind.SCALAR_TYPE_DEFINITION,
|
|
3748
|
-
description
|
|
3749
|
-
name
|
|
3750
|
-
directives
|
|
3751
|
-
|
|
3752
|
-
};
|
|
3923
|
+
description,
|
|
3924
|
+
name,
|
|
3925
|
+
directives,
|
|
3926
|
+
});
|
|
3753
3927
|
}
|
|
3754
3928
|
/**
|
|
3755
3929
|
* ObjectTypeDefinition :
|
|
3756
3930
|
* Description?
|
|
3757
3931
|
* type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
|
|
3758
3932
|
*/
|
|
3759
|
-
;
|
|
3760
3933
|
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3934
|
+
parseObjectTypeDefinition() {
|
|
3935
|
+
const start = this._lexer.token;
|
|
3936
|
+
const description = this.parseDescription();
|
|
3764
3937
|
this.expectKeyword('type');
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
return {
|
|
3938
|
+
const name = this.parseName();
|
|
3939
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
3940
|
+
const directives = this.parseConstDirectives();
|
|
3941
|
+
const fields = this.parseFieldsDefinition();
|
|
3942
|
+
return this.node(start, {
|
|
3770
3943
|
kind: Kind.OBJECT_TYPE_DEFINITION,
|
|
3771
|
-
description
|
|
3772
|
-
name
|
|
3773
|
-
interfaces
|
|
3774
|
-
directives
|
|
3775
|
-
fields
|
|
3776
|
-
|
|
3777
|
-
};
|
|
3944
|
+
description,
|
|
3945
|
+
name,
|
|
3946
|
+
interfaces,
|
|
3947
|
+
directives,
|
|
3948
|
+
fields,
|
|
3949
|
+
});
|
|
3778
3950
|
}
|
|
3779
3951
|
/**
|
|
3780
3952
|
* ImplementsInterfaces :
|
|
3781
3953
|
* - implements `&`? NamedType
|
|
3782
3954
|
* - ImplementsInterfaces & NamedType
|
|
3783
3955
|
*/
|
|
3784
|
-
;
|
|
3785
|
-
|
|
3786
|
-
_proto.parseImplementsInterfaces = function parseImplementsInterfaces() {
|
|
3787
|
-
var _this$_options2;
|
|
3788
|
-
|
|
3789
|
-
if (!this.expectOptionalKeyword('implements')) {
|
|
3790
|
-
return [];
|
|
3791
|
-
}
|
|
3792
|
-
|
|
3793
|
-
if (((_this$_options2 = this._options) === null || _this$_options2 === void 0 ? void 0 : _this$_options2.allowLegacySDLImplementsInterfaces) === true) {
|
|
3794
|
-
var types = []; // Optional leading ampersand
|
|
3795
|
-
|
|
3796
|
-
this.expectOptionalToken(TokenKind.AMP);
|
|
3797
|
-
|
|
3798
|
-
do {
|
|
3799
|
-
types.push(this.parseNamedType());
|
|
3800
|
-
} while (this.expectOptionalToken(TokenKind.AMP) || this.peek(TokenKind.NAME));
|
|
3801
3956
|
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3957
|
+
parseImplementsInterfaces() {
|
|
3958
|
+
return this.expectOptionalKeyword('implements')
|
|
3959
|
+
? this.delimitedMany(TokenKind.AMP, this.parseNamedType)
|
|
3960
|
+
: [];
|
|
3806
3961
|
}
|
|
3807
3962
|
/**
|
|
3963
|
+
* ```
|
|
3808
3964
|
* FieldsDefinition : { FieldDefinition+ }
|
|
3965
|
+
* ```
|
|
3809
3966
|
*/
|
|
3810
|
-
;
|
|
3811
|
-
|
|
3812
|
-
_proto.parseFieldsDefinition = function parseFieldsDefinition() {
|
|
3813
|
-
var _this$_options3;
|
|
3814
|
-
|
|
3815
|
-
// Legacy support for the SDL?
|
|
3816
|
-
if (((_this$_options3 = this._options) === null || _this$_options3 === void 0 ? void 0 : _this$_options3.allowLegacySDLEmptyFields) === true && this.peek(TokenKind.BRACE_L) && this._lexer.lookahead().kind === TokenKind.BRACE_R) {
|
|
3817
|
-
this._lexer.advance();
|
|
3818
|
-
|
|
3819
|
-
this._lexer.advance();
|
|
3820
|
-
|
|
3821
|
-
return [];
|
|
3822
|
-
}
|
|
3823
3967
|
|
|
3824
|
-
|
|
3968
|
+
parseFieldsDefinition() {
|
|
3969
|
+
return this.optionalMany(
|
|
3970
|
+
TokenKind.BRACE_L,
|
|
3971
|
+
this.parseFieldDefinition,
|
|
3972
|
+
TokenKind.BRACE_R,
|
|
3973
|
+
);
|
|
3825
3974
|
}
|
|
3826
3975
|
/**
|
|
3827
3976
|
* FieldDefinition :
|
|
3828
3977
|
* - Description? Name ArgumentsDefinition? : Type Directives[Const]?
|
|
3829
3978
|
*/
|
|
3830
|
-
;
|
|
3831
3979
|
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3980
|
+
parseFieldDefinition() {
|
|
3981
|
+
const start = this._lexer.token;
|
|
3982
|
+
const description = this.parseDescription();
|
|
3983
|
+
const name = this.parseName();
|
|
3984
|
+
const args = this.parseArgumentDefs();
|
|
3837
3985
|
this.expectToken(TokenKind.COLON);
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
return {
|
|
3986
|
+
const type = this.parseTypeReference();
|
|
3987
|
+
const directives = this.parseConstDirectives();
|
|
3988
|
+
return this.node(start, {
|
|
3841
3989
|
kind: Kind.FIELD_DEFINITION,
|
|
3842
|
-
description
|
|
3843
|
-
name
|
|
3990
|
+
description,
|
|
3991
|
+
name,
|
|
3844
3992
|
arguments: args,
|
|
3845
|
-
type
|
|
3846
|
-
directives
|
|
3847
|
-
|
|
3848
|
-
};
|
|
3993
|
+
type,
|
|
3994
|
+
directives,
|
|
3995
|
+
});
|
|
3849
3996
|
}
|
|
3850
3997
|
/**
|
|
3851
3998
|
* ArgumentsDefinition : ( InputValueDefinition+ )
|
|
3852
3999
|
*/
|
|
3853
|
-
;
|
|
3854
4000
|
|
|
3855
|
-
|
|
3856
|
-
return this.optionalMany(
|
|
4001
|
+
parseArgumentDefs() {
|
|
4002
|
+
return this.optionalMany(
|
|
4003
|
+
TokenKind.PAREN_L,
|
|
4004
|
+
this.parseInputValueDef,
|
|
4005
|
+
TokenKind.PAREN_R,
|
|
4006
|
+
);
|
|
3857
4007
|
}
|
|
3858
4008
|
/**
|
|
3859
4009
|
* InputValueDefinition :
|
|
3860
4010
|
* - Description? Name : Type DefaultValue? Directives[Const]?
|
|
3861
4011
|
*/
|
|
3862
|
-
;
|
|
3863
4012
|
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
4013
|
+
parseInputValueDef() {
|
|
4014
|
+
const start = this._lexer.token;
|
|
4015
|
+
const description = this.parseDescription();
|
|
4016
|
+
const name = this.parseName();
|
|
3868
4017
|
this.expectToken(TokenKind.COLON);
|
|
3869
|
-
|
|
3870
|
-
|
|
4018
|
+
const type = this.parseTypeReference();
|
|
4019
|
+
let defaultValue;
|
|
3871
4020
|
|
|
3872
4021
|
if (this.expectOptionalToken(TokenKind.EQUALS)) {
|
|
3873
|
-
defaultValue = this.
|
|
4022
|
+
defaultValue = this.parseConstValueLiteral();
|
|
3874
4023
|
}
|
|
3875
4024
|
|
|
3876
|
-
|
|
3877
|
-
return {
|
|
4025
|
+
const directives = this.parseConstDirectives();
|
|
4026
|
+
return this.node(start, {
|
|
3878
4027
|
kind: Kind.INPUT_VALUE_DEFINITION,
|
|
3879
|
-
description
|
|
3880
|
-
name
|
|
3881
|
-
type
|
|
3882
|
-
defaultValue
|
|
3883
|
-
directives
|
|
3884
|
-
|
|
3885
|
-
};
|
|
4028
|
+
description,
|
|
4029
|
+
name,
|
|
4030
|
+
type,
|
|
4031
|
+
defaultValue,
|
|
4032
|
+
directives,
|
|
4033
|
+
});
|
|
3886
4034
|
}
|
|
3887
4035
|
/**
|
|
3888
4036
|
* InterfaceTypeDefinition :
|
|
3889
4037
|
* - Description? interface Name Directives[Const]? FieldsDefinition?
|
|
3890
4038
|
*/
|
|
3891
|
-
;
|
|
3892
4039
|
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
4040
|
+
parseInterfaceTypeDefinition() {
|
|
4041
|
+
const start = this._lexer.token;
|
|
4042
|
+
const description = this.parseDescription();
|
|
3896
4043
|
this.expectKeyword('interface');
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
return {
|
|
4044
|
+
const name = this.parseName();
|
|
4045
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
4046
|
+
const directives = this.parseConstDirectives();
|
|
4047
|
+
const fields = this.parseFieldsDefinition();
|
|
4048
|
+
return this.node(start, {
|
|
3902
4049
|
kind: Kind.INTERFACE_TYPE_DEFINITION,
|
|
3903
|
-
description
|
|
3904
|
-
name
|
|
3905
|
-
interfaces
|
|
3906
|
-
directives
|
|
3907
|
-
fields
|
|
3908
|
-
|
|
3909
|
-
};
|
|
4050
|
+
description,
|
|
4051
|
+
name,
|
|
4052
|
+
interfaces,
|
|
4053
|
+
directives,
|
|
4054
|
+
fields,
|
|
4055
|
+
});
|
|
3910
4056
|
}
|
|
3911
4057
|
/**
|
|
3912
4058
|
* UnionTypeDefinition :
|
|
3913
4059
|
* - Description? union Name Directives[Const]? UnionMemberTypes?
|
|
3914
4060
|
*/
|
|
3915
|
-
;
|
|
3916
4061
|
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
4062
|
+
parseUnionTypeDefinition() {
|
|
4063
|
+
const start = this._lexer.token;
|
|
4064
|
+
const description = this.parseDescription();
|
|
3920
4065
|
this.expectKeyword('union');
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
return {
|
|
4066
|
+
const name = this.parseName();
|
|
4067
|
+
const directives = this.parseConstDirectives();
|
|
4068
|
+
const types = this.parseUnionMemberTypes();
|
|
4069
|
+
return this.node(start, {
|
|
3925
4070
|
kind: Kind.UNION_TYPE_DEFINITION,
|
|
3926
|
-
description
|
|
3927
|
-
name
|
|
3928
|
-
directives
|
|
3929
|
-
types
|
|
3930
|
-
|
|
3931
|
-
};
|
|
4071
|
+
description,
|
|
4072
|
+
name,
|
|
4073
|
+
directives,
|
|
4074
|
+
types,
|
|
4075
|
+
});
|
|
3932
4076
|
}
|
|
3933
4077
|
/**
|
|
3934
4078
|
* UnionMemberTypes :
|
|
3935
4079
|
* - = `|`? NamedType
|
|
3936
4080
|
* - UnionMemberTypes | NamedType
|
|
3937
4081
|
*/
|
|
3938
|
-
;
|
|
3939
4082
|
|
|
3940
|
-
|
|
3941
|
-
return this.expectOptionalToken(TokenKind.EQUALS)
|
|
4083
|
+
parseUnionMemberTypes() {
|
|
4084
|
+
return this.expectOptionalToken(TokenKind.EQUALS)
|
|
4085
|
+
? this.delimitedMany(TokenKind.PIPE, this.parseNamedType)
|
|
4086
|
+
: [];
|
|
3942
4087
|
}
|
|
3943
4088
|
/**
|
|
3944
4089
|
* EnumTypeDefinition :
|
|
3945
4090
|
* - Description? enum Name Directives[Const]? EnumValuesDefinition?
|
|
3946
4091
|
*/
|
|
3947
|
-
;
|
|
3948
4092
|
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
4093
|
+
parseEnumTypeDefinition() {
|
|
4094
|
+
const start = this._lexer.token;
|
|
4095
|
+
const description = this.parseDescription();
|
|
3952
4096
|
this.expectKeyword('enum');
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
return {
|
|
4097
|
+
const name = this.parseName();
|
|
4098
|
+
const directives = this.parseConstDirectives();
|
|
4099
|
+
const values = this.parseEnumValuesDefinition();
|
|
4100
|
+
return this.node(start, {
|
|
3957
4101
|
kind: Kind.ENUM_TYPE_DEFINITION,
|
|
3958
|
-
description
|
|
3959
|
-
name
|
|
3960
|
-
directives
|
|
3961
|
-
values
|
|
3962
|
-
|
|
3963
|
-
};
|
|
4102
|
+
description,
|
|
4103
|
+
name,
|
|
4104
|
+
directives,
|
|
4105
|
+
values,
|
|
4106
|
+
});
|
|
3964
4107
|
}
|
|
3965
4108
|
/**
|
|
4109
|
+
* ```
|
|
3966
4110
|
* EnumValuesDefinition : { EnumValueDefinition+ }
|
|
4111
|
+
* ```
|
|
3967
4112
|
*/
|
|
3968
|
-
;
|
|
3969
4113
|
|
|
3970
|
-
|
|
3971
|
-
return this.optionalMany(
|
|
4114
|
+
parseEnumValuesDefinition() {
|
|
4115
|
+
return this.optionalMany(
|
|
4116
|
+
TokenKind.BRACE_L,
|
|
4117
|
+
this.parseEnumValueDefinition,
|
|
4118
|
+
TokenKind.BRACE_R,
|
|
4119
|
+
);
|
|
3972
4120
|
}
|
|
3973
4121
|
/**
|
|
3974
4122
|
* EnumValueDefinition : Description? EnumValue Directives[Const]?
|
|
3975
|
-
*
|
|
3976
|
-
* EnumValue : Name
|
|
3977
4123
|
*/
|
|
3978
|
-
;
|
|
3979
4124
|
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
return {
|
|
4125
|
+
parseEnumValueDefinition() {
|
|
4126
|
+
const start = this._lexer.token;
|
|
4127
|
+
const description = this.parseDescription();
|
|
4128
|
+
const name = this.parseEnumValueName();
|
|
4129
|
+
const directives = this.parseConstDirectives();
|
|
4130
|
+
return this.node(start, {
|
|
3986
4131
|
kind: Kind.ENUM_VALUE_DEFINITION,
|
|
3987
|
-
description
|
|
3988
|
-
name
|
|
3989
|
-
directives
|
|
3990
|
-
|
|
3991
|
-
|
|
4132
|
+
description,
|
|
4133
|
+
name,
|
|
4134
|
+
directives,
|
|
4135
|
+
});
|
|
4136
|
+
}
|
|
4137
|
+
/**
|
|
4138
|
+
* EnumValue : Name but not `true`, `false` or `null`
|
|
4139
|
+
*/
|
|
4140
|
+
|
|
4141
|
+
parseEnumValueName() {
|
|
4142
|
+
if (
|
|
4143
|
+
this._lexer.token.value === 'true' ||
|
|
4144
|
+
this._lexer.token.value === 'false' ||
|
|
4145
|
+
this._lexer.token.value === 'null'
|
|
4146
|
+
) {
|
|
4147
|
+
throw syntaxError(
|
|
4148
|
+
this._lexer.source,
|
|
4149
|
+
this._lexer.token.start,
|
|
4150
|
+
`${getTokenDesc(
|
|
4151
|
+
this._lexer.token,
|
|
4152
|
+
)} is reserved and cannot be used for an enum value.`,
|
|
4153
|
+
);
|
|
4154
|
+
}
|
|
4155
|
+
|
|
4156
|
+
return this.parseName();
|
|
3992
4157
|
}
|
|
3993
4158
|
/**
|
|
3994
4159
|
* InputObjectTypeDefinition :
|
|
3995
4160
|
* - Description? input Name Directives[Const]? InputFieldsDefinition?
|
|
3996
4161
|
*/
|
|
3997
|
-
;
|
|
3998
4162
|
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4163
|
+
parseInputObjectTypeDefinition() {
|
|
4164
|
+
const start = this._lexer.token;
|
|
4165
|
+
const description = this.parseDescription();
|
|
4002
4166
|
this.expectKeyword('input');
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
return {
|
|
4167
|
+
const name = this.parseName();
|
|
4168
|
+
const directives = this.parseConstDirectives();
|
|
4169
|
+
const fields = this.parseInputFieldsDefinition();
|
|
4170
|
+
return this.node(start, {
|
|
4007
4171
|
kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
4008
|
-
description
|
|
4009
|
-
name
|
|
4010
|
-
directives
|
|
4011
|
-
fields
|
|
4012
|
-
|
|
4013
|
-
};
|
|
4172
|
+
description,
|
|
4173
|
+
name,
|
|
4174
|
+
directives,
|
|
4175
|
+
fields,
|
|
4176
|
+
});
|
|
4014
4177
|
}
|
|
4015
4178
|
/**
|
|
4179
|
+
* ```
|
|
4016
4180
|
* InputFieldsDefinition : { InputValueDefinition+ }
|
|
4181
|
+
* ```
|
|
4017
4182
|
*/
|
|
4018
|
-
;
|
|
4019
4183
|
|
|
4020
|
-
|
|
4021
|
-
return this.optionalMany(
|
|
4184
|
+
parseInputFieldsDefinition() {
|
|
4185
|
+
return this.optionalMany(
|
|
4186
|
+
TokenKind.BRACE_L,
|
|
4187
|
+
this.parseInputValueDef,
|
|
4188
|
+
TokenKind.BRACE_R,
|
|
4189
|
+
);
|
|
4022
4190
|
}
|
|
4023
4191
|
/**
|
|
4024
4192
|
* TypeSystemExtension :
|
|
@@ -4033,10 +4201,9 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4033
4201
|
* - EnumTypeExtension
|
|
4034
4202
|
* - InputObjectTypeDefinition
|
|
4035
4203
|
*/
|
|
4036
|
-
;
|
|
4037
4204
|
|
|
4038
|
-
|
|
4039
|
-
|
|
4205
|
+
parseTypeSystemExtension() {
|
|
4206
|
+
const keywordToken = this._lexer.lookahead();
|
|
4040
4207
|
|
|
4041
4208
|
if (keywordToken.kind === TokenKind.NAME) {
|
|
4042
4209
|
switch (keywordToken.value) {
|
|
@@ -4066,53 +4233,55 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4066
4233
|
throw this.unexpected(keywordToken);
|
|
4067
4234
|
}
|
|
4068
4235
|
/**
|
|
4236
|
+
* ```
|
|
4069
4237
|
* SchemaExtension :
|
|
4070
4238
|
* - extend schema Directives[Const]? { OperationTypeDefinition+ }
|
|
4071
4239
|
* - extend schema Directives[Const]
|
|
4240
|
+
* ```
|
|
4072
4241
|
*/
|
|
4073
|
-
;
|
|
4074
4242
|
|
|
4075
|
-
|
|
4076
|
-
|
|
4243
|
+
parseSchemaExtension() {
|
|
4244
|
+
const start = this._lexer.token;
|
|
4077
4245
|
this.expectKeyword('extend');
|
|
4078
4246
|
this.expectKeyword('schema');
|
|
4079
|
-
|
|
4080
|
-
|
|
4247
|
+
const directives = this.parseConstDirectives();
|
|
4248
|
+
const operationTypes = this.optionalMany(
|
|
4249
|
+
TokenKind.BRACE_L,
|
|
4250
|
+
this.parseOperationTypeDefinition,
|
|
4251
|
+
TokenKind.BRACE_R,
|
|
4252
|
+
);
|
|
4081
4253
|
|
|
4082
4254
|
if (directives.length === 0 && operationTypes.length === 0) {
|
|
4083
4255
|
throw this.unexpected();
|
|
4084
4256
|
}
|
|
4085
4257
|
|
|
4086
|
-
return {
|
|
4258
|
+
return this.node(start, {
|
|
4087
4259
|
kind: Kind.SCHEMA_EXTENSION,
|
|
4088
|
-
directives
|
|
4089
|
-
operationTypes
|
|
4090
|
-
|
|
4091
|
-
};
|
|
4260
|
+
directives,
|
|
4261
|
+
operationTypes,
|
|
4262
|
+
});
|
|
4092
4263
|
}
|
|
4093
4264
|
/**
|
|
4094
4265
|
* ScalarTypeExtension :
|
|
4095
4266
|
* - extend scalar Name Directives[Const]
|
|
4096
4267
|
*/
|
|
4097
|
-
;
|
|
4098
4268
|
|
|
4099
|
-
|
|
4100
|
-
|
|
4269
|
+
parseScalarTypeExtension() {
|
|
4270
|
+
const start = this._lexer.token;
|
|
4101
4271
|
this.expectKeyword('extend');
|
|
4102
4272
|
this.expectKeyword('scalar');
|
|
4103
|
-
|
|
4104
|
-
|
|
4273
|
+
const name = this.parseName();
|
|
4274
|
+
const directives = this.parseConstDirectives();
|
|
4105
4275
|
|
|
4106
4276
|
if (directives.length === 0) {
|
|
4107
4277
|
throw this.unexpected();
|
|
4108
4278
|
}
|
|
4109
4279
|
|
|
4110
|
-
return {
|
|
4280
|
+
return this.node(start, {
|
|
4111
4281
|
kind: Kind.SCALAR_TYPE_EXTENSION,
|
|
4112
|
-
name
|
|
4113
|
-
directives
|
|
4114
|
-
|
|
4115
|
-
};
|
|
4282
|
+
name,
|
|
4283
|
+
directives,
|
|
4284
|
+
});
|
|
4116
4285
|
}
|
|
4117
4286
|
/**
|
|
4118
4287
|
* ObjectTypeExtension :
|
|
@@ -4120,29 +4289,31 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4120
4289
|
* - extend type Name ImplementsInterfaces? Directives[Const]
|
|
4121
4290
|
* - extend type Name ImplementsInterfaces
|
|
4122
4291
|
*/
|
|
4123
|
-
;
|
|
4124
4292
|
|
|
4125
|
-
|
|
4126
|
-
|
|
4293
|
+
parseObjectTypeExtension() {
|
|
4294
|
+
const start = this._lexer.token;
|
|
4127
4295
|
this.expectKeyword('extend');
|
|
4128
4296
|
this.expectKeyword('type');
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
if (
|
|
4297
|
+
const name = this.parseName();
|
|
4298
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
4299
|
+
const directives = this.parseConstDirectives();
|
|
4300
|
+
const fields = this.parseFieldsDefinition();
|
|
4301
|
+
|
|
4302
|
+
if (
|
|
4303
|
+
interfaces.length === 0 &&
|
|
4304
|
+
directives.length === 0 &&
|
|
4305
|
+
fields.length === 0
|
|
4306
|
+
) {
|
|
4135
4307
|
throw this.unexpected();
|
|
4136
4308
|
}
|
|
4137
4309
|
|
|
4138
|
-
return {
|
|
4310
|
+
return this.node(start, {
|
|
4139
4311
|
kind: Kind.OBJECT_TYPE_EXTENSION,
|
|
4140
|
-
name
|
|
4141
|
-
interfaces
|
|
4142
|
-
directives
|
|
4143
|
-
fields
|
|
4144
|
-
|
|
4145
|
-
};
|
|
4312
|
+
name,
|
|
4313
|
+
interfaces,
|
|
4314
|
+
directives,
|
|
4315
|
+
fields,
|
|
4316
|
+
});
|
|
4146
4317
|
}
|
|
4147
4318
|
/**
|
|
4148
4319
|
* InterfaceTypeExtension :
|
|
@@ -4150,145 +4321,140 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4150
4321
|
* - extend interface Name ImplementsInterfaces? Directives[Const]
|
|
4151
4322
|
* - extend interface Name ImplementsInterfaces
|
|
4152
4323
|
*/
|
|
4153
|
-
;
|
|
4154
4324
|
|
|
4155
|
-
|
|
4156
|
-
|
|
4325
|
+
parseInterfaceTypeExtension() {
|
|
4326
|
+
const start = this._lexer.token;
|
|
4157
4327
|
this.expectKeyword('extend');
|
|
4158
4328
|
this.expectKeyword('interface');
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
if (
|
|
4329
|
+
const name = this.parseName();
|
|
4330
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
4331
|
+
const directives = this.parseConstDirectives();
|
|
4332
|
+
const fields = this.parseFieldsDefinition();
|
|
4333
|
+
|
|
4334
|
+
if (
|
|
4335
|
+
interfaces.length === 0 &&
|
|
4336
|
+
directives.length === 0 &&
|
|
4337
|
+
fields.length === 0
|
|
4338
|
+
) {
|
|
4165
4339
|
throw this.unexpected();
|
|
4166
4340
|
}
|
|
4167
4341
|
|
|
4168
|
-
return {
|
|
4342
|
+
return this.node(start, {
|
|
4169
4343
|
kind: Kind.INTERFACE_TYPE_EXTENSION,
|
|
4170
|
-
name
|
|
4171
|
-
interfaces
|
|
4172
|
-
directives
|
|
4173
|
-
fields
|
|
4174
|
-
|
|
4175
|
-
};
|
|
4344
|
+
name,
|
|
4345
|
+
interfaces,
|
|
4346
|
+
directives,
|
|
4347
|
+
fields,
|
|
4348
|
+
});
|
|
4176
4349
|
}
|
|
4177
4350
|
/**
|
|
4178
4351
|
* UnionTypeExtension :
|
|
4179
4352
|
* - extend union Name Directives[Const]? UnionMemberTypes
|
|
4180
4353
|
* - extend union Name Directives[Const]
|
|
4181
4354
|
*/
|
|
4182
|
-
;
|
|
4183
4355
|
|
|
4184
|
-
|
|
4185
|
-
|
|
4356
|
+
parseUnionTypeExtension() {
|
|
4357
|
+
const start = this._lexer.token;
|
|
4186
4358
|
this.expectKeyword('extend');
|
|
4187
4359
|
this.expectKeyword('union');
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4360
|
+
const name = this.parseName();
|
|
4361
|
+
const directives = this.parseConstDirectives();
|
|
4362
|
+
const types = this.parseUnionMemberTypes();
|
|
4191
4363
|
|
|
4192
4364
|
if (directives.length === 0 && types.length === 0) {
|
|
4193
4365
|
throw this.unexpected();
|
|
4194
4366
|
}
|
|
4195
4367
|
|
|
4196
|
-
return {
|
|
4368
|
+
return this.node(start, {
|
|
4197
4369
|
kind: Kind.UNION_TYPE_EXTENSION,
|
|
4198
|
-
name
|
|
4199
|
-
directives
|
|
4200
|
-
types
|
|
4201
|
-
|
|
4202
|
-
};
|
|
4370
|
+
name,
|
|
4371
|
+
directives,
|
|
4372
|
+
types,
|
|
4373
|
+
});
|
|
4203
4374
|
}
|
|
4204
4375
|
/**
|
|
4205
4376
|
* EnumTypeExtension :
|
|
4206
4377
|
* - extend enum Name Directives[Const]? EnumValuesDefinition
|
|
4207
4378
|
* - extend enum Name Directives[Const]
|
|
4208
4379
|
*/
|
|
4209
|
-
;
|
|
4210
4380
|
|
|
4211
|
-
|
|
4212
|
-
|
|
4381
|
+
parseEnumTypeExtension() {
|
|
4382
|
+
const start = this._lexer.token;
|
|
4213
4383
|
this.expectKeyword('extend');
|
|
4214
4384
|
this.expectKeyword('enum');
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4385
|
+
const name = this.parseName();
|
|
4386
|
+
const directives = this.parseConstDirectives();
|
|
4387
|
+
const values = this.parseEnumValuesDefinition();
|
|
4218
4388
|
|
|
4219
4389
|
if (directives.length === 0 && values.length === 0) {
|
|
4220
4390
|
throw this.unexpected();
|
|
4221
4391
|
}
|
|
4222
4392
|
|
|
4223
|
-
return {
|
|
4393
|
+
return this.node(start, {
|
|
4224
4394
|
kind: Kind.ENUM_TYPE_EXTENSION,
|
|
4225
|
-
name
|
|
4226
|
-
directives
|
|
4227
|
-
values
|
|
4228
|
-
|
|
4229
|
-
};
|
|
4395
|
+
name,
|
|
4396
|
+
directives,
|
|
4397
|
+
values,
|
|
4398
|
+
});
|
|
4230
4399
|
}
|
|
4231
4400
|
/**
|
|
4232
4401
|
* InputObjectTypeExtension :
|
|
4233
4402
|
* - extend input Name Directives[Const]? InputFieldsDefinition
|
|
4234
4403
|
* - extend input Name Directives[Const]
|
|
4235
4404
|
*/
|
|
4236
|
-
;
|
|
4237
4405
|
|
|
4238
|
-
|
|
4239
|
-
|
|
4406
|
+
parseInputObjectTypeExtension() {
|
|
4407
|
+
const start = this._lexer.token;
|
|
4240
4408
|
this.expectKeyword('extend');
|
|
4241
4409
|
this.expectKeyword('input');
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4410
|
+
const name = this.parseName();
|
|
4411
|
+
const directives = this.parseConstDirectives();
|
|
4412
|
+
const fields = this.parseInputFieldsDefinition();
|
|
4245
4413
|
|
|
4246
4414
|
if (directives.length === 0 && fields.length === 0) {
|
|
4247
4415
|
throw this.unexpected();
|
|
4248
4416
|
}
|
|
4249
4417
|
|
|
4250
|
-
return {
|
|
4418
|
+
return this.node(start, {
|
|
4251
4419
|
kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
|
|
4252
|
-
name
|
|
4253
|
-
directives
|
|
4254
|
-
fields
|
|
4255
|
-
|
|
4256
|
-
};
|
|
4420
|
+
name,
|
|
4421
|
+
directives,
|
|
4422
|
+
fields,
|
|
4423
|
+
});
|
|
4257
4424
|
}
|
|
4258
4425
|
/**
|
|
4426
|
+
* ```
|
|
4259
4427
|
* DirectiveDefinition :
|
|
4260
4428
|
* - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
|
|
4429
|
+
* ```
|
|
4261
4430
|
*/
|
|
4262
|
-
;
|
|
4263
4431
|
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4432
|
+
parseDirectiveDefinition() {
|
|
4433
|
+
const start = this._lexer.token;
|
|
4434
|
+
const description = this.parseDescription();
|
|
4267
4435
|
this.expectKeyword('directive');
|
|
4268
4436
|
this.expectToken(TokenKind.AT);
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4437
|
+
const name = this.parseName();
|
|
4438
|
+
const args = this.parseArgumentDefs();
|
|
4439
|
+
const repeatable = this.expectOptionalKeyword('repeatable');
|
|
4272
4440
|
this.expectKeyword('on');
|
|
4273
|
-
|
|
4274
|
-
return {
|
|
4441
|
+
const locations = this.parseDirectiveLocations();
|
|
4442
|
+
return this.node(start, {
|
|
4275
4443
|
kind: Kind.DIRECTIVE_DEFINITION,
|
|
4276
|
-
description
|
|
4277
|
-
name
|
|
4444
|
+
description,
|
|
4445
|
+
name,
|
|
4278
4446
|
arguments: args,
|
|
4279
|
-
repeatable
|
|
4280
|
-
locations
|
|
4281
|
-
|
|
4282
|
-
};
|
|
4447
|
+
repeatable,
|
|
4448
|
+
locations,
|
|
4449
|
+
});
|
|
4283
4450
|
}
|
|
4284
4451
|
/**
|
|
4285
4452
|
* DirectiveLocations :
|
|
4286
4453
|
* - `|`? DirectiveLocation
|
|
4287
4454
|
* - DirectiveLocations | DirectiveLocation
|
|
4288
4455
|
*/
|
|
4289
|
-
;
|
|
4290
4456
|
|
|
4291
|
-
|
|
4457
|
+
parseDirectiveLocations() {
|
|
4292
4458
|
return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
|
|
4293
4459
|
}
|
|
4294
4460
|
/*
|
|
@@ -4318,13 +4484,12 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4318
4484
|
* `INPUT_OBJECT`
|
|
4319
4485
|
* `INPUT_FIELD_DEFINITION`
|
|
4320
4486
|
*/
|
|
4321
|
-
;
|
|
4322
4487
|
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4488
|
+
parseDirectiveLocation() {
|
|
4489
|
+
const start = this._lexer.token;
|
|
4490
|
+
const name = this.parseName();
|
|
4326
4491
|
|
|
4327
|
-
if (DirectiveLocation
|
|
4492
|
+
if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) {
|
|
4328
4493
|
return name;
|
|
4329
4494
|
}
|
|
4330
4495
|
|
|
@@ -4332,33 +4497,42 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4332
4497
|
} // Core parsing utility functions
|
|
4333
4498
|
|
|
4334
4499
|
/**
|
|
4335
|
-
* Returns a
|
|
4500
|
+
* Returns a node that, if configured to do so, sets a "loc" field as a
|
|
4501
|
+
* location object, used to identify the place in the source that created a
|
|
4502
|
+
* given parsed object.
|
|
4336
4503
|
*/
|
|
4337
|
-
;
|
|
4338
4504
|
|
|
4339
|
-
|
|
4340
|
-
var _this$
|
|
4505
|
+
node(startToken, node) {
|
|
4506
|
+
var _this$_options2;
|
|
4341
4507
|
|
|
4342
|
-
if (
|
|
4343
|
-
|
|
4508
|
+
if (
|
|
4509
|
+
((_this$_options2 = this._options) === null || _this$_options2 === void 0
|
|
4510
|
+
? void 0
|
|
4511
|
+
: _this$_options2.noLocation) !== true
|
|
4512
|
+
) {
|
|
4513
|
+
node.loc = new Location(
|
|
4514
|
+
startToken,
|
|
4515
|
+
this._lexer.lastToken,
|
|
4516
|
+
this._lexer.source,
|
|
4517
|
+
);
|
|
4344
4518
|
}
|
|
4519
|
+
|
|
4520
|
+
return node;
|
|
4345
4521
|
}
|
|
4346
4522
|
/**
|
|
4347
4523
|
* Determines if the next token is of a given kind
|
|
4348
4524
|
*/
|
|
4349
|
-
;
|
|
4350
4525
|
|
|
4351
|
-
|
|
4526
|
+
peek(kind) {
|
|
4352
4527
|
return this._lexer.token.kind === kind;
|
|
4353
4528
|
}
|
|
4354
4529
|
/**
|
|
4355
4530
|
* If the next token is of the given kind, return that token after advancing the lexer.
|
|
4356
4531
|
* Otherwise, do not change the parser state and throw an error.
|
|
4357
4532
|
*/
|
|
4358
|
-
;
|
|
4359
4533
|
|
|
4360
|
-
|
|
4361
|
-
|
|
4534
|
+
expectToken(kind) {
|
|
4535
|
+
const token = this._lexer.token;
|
|
4362
4536
|
|
|
4363
4537
|
if (token.kind === kind) {
|
|
4364
4538
|
this._lexer.advance();
|
|
@@ -4366,48 +4540,53 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4366
4540
|
return token;
|
|
4367
4541
|
}
|
|
4368
4542
|
|
|
4369
|
-
throw syntaxError(
|
|
4543
|
+
throw syntaxError(
|
|
4544
|
+
this._lexer.source,
|
|
4545
|
+
token.start,
|
|
4546
|
+
`Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`,
|
|
4547
|
+
);
|
|
4370
4548
|
}
|
|
4371
4549
|
/**
|
|
4372
|
-
* If the next token is of the given kind, return
|
|
4373
|
-
* Otherwise, do not change the parser state and return
|
|
4550
|
+
* If the next token is of the given kind, return "true" after advancing the lexer.
|
|
4551
|
+
* Otherwise, do not change the parser state and return "false".
|
|
4374
4552
|
*/
|
|
4375
|
-
;
|
|
4376
4553
|
|
|
4377
|
-
|
|
4378
|
-
|
|
4554
|
+
expectOptionalToken(kind) {
|
|
4555
|
+
const token = this._lexer.token;
|
|
4379
4556
|
|
|
4380
4557
|
if (token.kind === kind) {
|
|
4381
4558
|
this._lexer.advance();
|
|
4382
4559
|
|
|
4383
|
-
return
|
|
4560
|
+
return true;
|
|
4384
4561
|
}
|
|
4385
4562
|
|
|
4386
|
-
return
|
|
4563
|
+
return false;
|
|
4387
4564
|
}
|
|
4388
4565
|
/**
|
|
4389
4566
|
* If the next token is a given keyword, advance the lexer.
|
|
4390
4567
|
* Otherwise, do not change the parser state and throw an error.
|
|
4391
4568
|
*/
|
|
4392
|
-
;
|
|
4393
4569
|
|
|
4394
|
-
|
|
4395
|
-
|
|
4570
|
+
expectKeyword(value) {
|
|
4571
|
+
const token = this._lexer.token;
|
|
4396
4572
|
|
|
4397
4573
|
if (token.kind === TokenKind.NAME && token.value === value) {
|
|
4398
4574
|
this._lexer.advance();
|
|
4399
4575
|
} else {
|
|
4400
|
-
throw syntaxError(
|
|
4576
|
+
throw syntaxError(
|
|
4577
|
+
this._lexer.source,
|
|
4578
|
+
token.start,
|
|
4579
|
+
`Expected "${value}", found ${getTokenDesc(token)}.`,
|
|
4580
|
+
);
|
|
4401
4581
|
}
|
|
4402
4582
|
}
|
|
4403
4583
|
/**
|
|
4404
4584
|
* If the next token is a given keyword, return "true" after advancing the lexer.
|
|
4405
4585
|
* Otherwise, do not change the parser state and return "false".
|
|
4406
4586
|
*/
|
|
4407
|
-
;
|
|
4408
4587
|
|
|
4409
|
-
|
|
4410
|
-
|
|
4588
|
+
expectOptionalKeyword(value) {
|
|
4589
|
+
const token = this._lexer.token;
|
|
4411
4590
|
|
|
4412
4591
|
if (token.kind === TokenKind.NAME && token.value === value) {
|
|
4413
4592
|
this._lexer.advance();
|
|
@@ -4420,22 +4599,25 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4420
4599
|
/**
|
|
4421
4600
|
* Helper function for creating an error when an unexpected lexed token is encountered.
|
|
4422
4601
|
*/
|
|
4423
|
-
;
|
|
4424
4602
|
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4603
|
+
unexpected(atToken) {
|
|
4604
|
+
const token =
|
|
4605
|
+
atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
|
|
4606
|
+
return syntaxError(
|
|
4607
|
+
this._lexer.source,
|
|
4608
|
+
token.start,
|
|
4609
|
+
`Unexpected ${getTokenDesc(token)}.`,
|
|
4610
|
+
);
|
|
4428
4611
|
}
|
|
4429
4612
|
/**
|
|
4430
4613
|
* Returns a possibly empty list of parse nodes, determined by the parseFn.
|
|
4431
4614
|
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
4432
4615
|
* Advances the parser to the next lex token after the closing token.
|
|
4433
4616
|
*/
|
|
4434
|
-
;
|
|
4435
4617
|
|
|
4436
|
-
|
|
4618
|
+
any(openKind, parseFn, closeKind) {
|
|
4437
4619
|
this.expectToken(openKind);
|
|
4438
|
-
|
|
4620
|
+
const nodes = [];
|
|
4439
4621
|
|
|
4440
4622
|
while (!this.expectOptionalToken(closeKind)) {
|
|
4441
4623
|
nodes.push(parseFn.call(this));
|
|
@@ -4449,11 +4631,10 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4449
4631
|
* that begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
4450
4632
|
* Advances the parser to the next lex token after the closing token.
|
|
4451
4633
|
*/
|
|
4452
|
-
;
|
|
4453
4634
|
|
|
4454
|
-
|
|
4635
|
+
optionalMany(openKind, parseFn, closeKind) {
|
|
4455
4636
|
if (this.expectOptionalToken(openKind)) {
|
|
4456
|
-
|
|
4637
|
+
const nodes = [];
|
|
4457
4638
|
|
|
4458
4639
|
do {
|
|
4459
4640
|
nodes.push(parseFn.call(this));
|
|
@@ -4469,11 +4650,10 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4469
4650
|
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
4470
4651
|
* Advances the parser to the next lex token after the closing token.
|
|
4471
4652
|
*/
|
|
4472
|
-
;
|
|
4473
4653
|
|
|
4474
|
-
|
|
4654
|
+
many(openKind, parseFn, closeKind) {
|
|
4475
4655
|
this.expectToken(openKind);
|
|
4476
|
-
|
|
4656
|
+
const nodes = [];
|
|
4477
4657
|
|
|
4478
4658
|
do {
|
|
4479
4659
|
nodes.push(parseFn.call(this));
|
|
@@ -4486,36 +4666,32 @@ var Parser = /*#__PURE__*/function () {
|
|
|
4486
4666
|
* This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
|
|
4487
4667
|
* Advances the parser to the next lex token after last item in the list.
|
|
4488
4668
|
*/
|
|
4489
|
-
;
|
|
4490
4669
|
|
|
4491
|
-
|
|
4670
|
+
delimitedMany(delimiterKind, parseFn) {
|
|
4492
4671
|
this.expectOptionalToken(delimiterKind);
|
|
4493
|
-
|
|
4672
|
+
const nodes = [];
|
|
4494
4673
|
|
|
4495
4674
|
do {
|
|
4496
4675
|
nodes.push(parseFn.call(this));
|
|
4497
4676
|
} while (this.expectOptionalToken(delimiterKind));
|
|
4498
4677
|
|
|
4499
4678
|
return nodes;
|
|
4500
|
-
}
|
|
4501
|
-
|
|
4502
|
-
return Parser;
|
|
4503
|
-
}();
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4504
4681
|
/**
|
|
4505
4682
|
* A helper function to describe a token as a string for debugging.
|
|
4506
4683
|
*/
|
|
4507
4684
|
|
|
4508
4685
|
function getTokenDesc(token) {
|
|
4509
|
-
|
|
4510
|
-
return getTokenKindDesc(token.kind) + (value != null ?
|
|
4686
|
+
const value = token.value;
|
|
4687
|
+
return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : '');
|
|
4511
4688
|
}
|
|
4512
4689
|
/**
|
|
4513
4690
|
* A helper function to describe a token kind as a string for debugging.
|
|
4514
4691
|
*/
|
|
4515
4692
|
|
|
4516
|
-
|
|
4517
4693
|
function getTokenKindDesc(kind) {
|
|
4518
|
-
return isPunctuatorTokenKind(kind) ? "
|
|
4694
|
+
return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind;
|
|
4519
4695
|
}
|
|
4520
4696
|
|
|
4521
4697
|
/**
|
|
@@ -5896,56 +6072,71 @@ ${handlers.map((handler) => ` • ${handler.info.header}`).join('\n')}`;
|
|
|
5896
6072
|
return `Did you mean to request "${handlers[0].info.header}" instead?`;
|
|
5897
6073
|
}
|
|
5898
6074
|
function onUnhandledRequest(request, handlers, strategy = 'warn') {
|
|
5899
|
-
if (typeof strategy === 'function') {
|
|
5900
|
-
strategy(request);
|
|
5901
|
-
return;
|
|
5902
|
-
}
|
|
5903
|
-
/**
|
|
5904
|
-
* @note Ignore exceptions during GraphQL request parsing because at this point
|
|
5905
|
-
* we cannot assume the unhandled request is a valid GraphQL request.
|
|
5906
|
-
* If the GraphQL parsing fails, just don't treat it as a GraphQL request.
|
|
5907
|
-
*/
|
|
5908
6075
|
const parsedGraphQLQuery = tryCatch(() => parseGraphQLRequest(request));
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
6076
|
+
function generateHandlerSuggestion() {
|
|
6077
|
+
/**
|
|
6078
|
+
* @note Ignore exceptions during GraphQL request parsing because at this point
|
|
6079
|
+
* we cannot assume the unhandled request is a valid GraphQL request.
|
|
6080
|
+
* If the GraphQL parsing fails, just don't treat it as a GraphQL request.
|
|
6081
|
+
*/
|
|
6082
|
+
const handlerGroups = groupHandlersByType(handlers);
|
|
6083
|
+
const relevantHandlers = parsedGraphQLQuery
|
|
6084
|
+
? handlerGroups.graphql
|
|
6085
|
+
: handlerGroups.rest;
|
|
6086
|
+
const suggestedHandlers = getSuggestedHandler(request, relevantHandlers, parsedGraphQLQuery
|
|
6087
|
+
? getGraphQLHandlerScore(parsedGraphQLQuery)
|
|
6088
|
+
: getRestHandlerScore());
|
|
6089
|
+
return suggestedHandlers.length > 0
|
|
6090
|
+
? getSuggestedHandlersMessage(suggestedHandlers)
|
|
6091
|
+
: '';
|
|
6092
|
+
}
|
|
6093
|
+
function generateUnhandledRequestMessage() {
|
|
6094
|
+
const publicUrl = getPublicUrlFromRequest(request);
|
|
6095
|
+
const requestHeader = parsedGraphQLQuery
|
|
6096
|
+
? `${parsedGraphQLQuery.operationType} ${parsedGraphQLQuery.operationName} (${request.method} ${publicUrl})`
|
|
6097
|
+
: `${request.method} ${publicUrl}`;
|
|
6098
|
+
const handlerSuggestion = generateHandlerSuggestion();
|
|
6099
|
+
const messageTemplate = [
|
|
6100
|
+
`captured a request without a matching request handler:`,
|
|
6101
|
+
` \u2022 ${requestHeader}`,
|
|
6102
|
+
handlerSuggestion,
|
|
6103
|
+
`\
|
|
5928
6104
|
If you still wish to intercept this unhandled request, please create a request handler for it.
|
|
5929
6105
|
Read more: https://mswjs.io/docs/getting-started/mocks\
|
|
5930
6106
|
`,
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
6107
|
+
].filter(Boolean);
|
|
6108
|
+
return messageTemplate.join('\n\n');
|
|
6109
|
+
}
|
|
6110
|
+
function applyStrategy(strategy) {
|
|
6111
|
+
// Generate handler suggestions only when applying the strategy.
|
|
6112
|
+
// This saves bandwidth for scenarios when developers opt-out
|
|
6113
|
+
// from the default unhandled request handling strategy.
|
|
6114
|
+
const message = generateUnhandledRequestMessage();
|
|
6115
|
+
switch (strategy) {
|
|
6116
|
+
case 'error': {
|
|
6117
|
+
// Print a developer-friendly error.
|
|
6118
|
+
devUtils.error('Error: %s', message);
|
|
6119
|
+
// Throw an exception to halt request processing and not perform the original request.
|
|
6120
|
+
throw new Error(devUtils.formatMessage('Cannot bypass a request when using the "error" strategy for the "onUnhandledRequest" option.'));
|
|
6121
|
+
}
|
|
6122
|
+
case 'warn': {
|
|
6123
|
+
devUtils.warn('Warning: %s', message);
|
|
6124
|
+
break;
|
|
6125
|
+
}
|
|
6126
|
+
case 'bypass':
|
|
6127
|
+
break;
|
|
6128
|
+
default:
|
|
6129
|
+
throw new Error(devUtils.formatMessage('Failed to react to an unhandled request: unknown strategy "%s". Please provide one of the supported strategies ("bypass", "warn", "error") or a custom callback function as the value of the "onUnhandledRequest" option.', strategy));
|
|
5943
6130
|
}
|
|
5944
|
-
case 'bypass':
|
|
5945
|
-
break;
|
|
5946
|
-
default:
|
|
5947
|
-
throw new Error(devUtils.formatMessage('Failed to react to an unhandled request: unknown strategy "%s". Please provide one of the supported strategies ("bypass", "warn", "error") or a custom callback function as the value of the "onUnhandledRequest" option.', strategy));
|
|
5948
6131
|
}
|
|
6132
|
+
if (typeof strategy === 'function') {
|
|
6133
|
+
strategy(request, {
|
|
6134
|
+
warning: applyStrategy.bind(null, 'warn'),
|
|
6135
|
+
error: applyStrategy.bind(null, 'error'),
|
|
6136
|
+
});
|
|
6137
|
+
return;
|
|
6138
|
+
}
|
|
6139
|
+
applyStrategy(strategy);
|
|
5949
6140
|
}
|
|
5950
6141
|
|
|
5951
6142
|
function readResponseCookies(request, response) {
|