@luvio/graphql-parser 0.103.0 → 0.104.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.
@@ -2,226 +2,30 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- // In ES2015 (or a polyfilled) environment, this will be Symbol.iterator
6
- // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
7
- var SYMBOL_ITERATOR = typeof Symbol === 'function' && Symbol.iterator != null ? Symbol.iterator : '@@iterator'; // In ES2017 (or a polyfilled) environment, this will be Symbol.asyncIterator
8
-
9
- var SYMBOL_TO_STRING_TAG = typeof Symbol === 'function' && Symbol.toStringTag != null ? Symbol.toStringTag : '@@toStringTag';
10
-
11
- // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
12
- var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
13
- var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
14
-
15
- function _typeof$4(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$4 = function _typeof(obj) { return typeof obj; }; } else { _typeof$4 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$4(obj); }
16
- var MAX_ARRAY_LENGTH = 10;
17
- var MAX_RECURSIVE_DEPTH = 2;
18
5
  /**
19
- * Used to print values in error messages.
6
+ * Returns true if the value acts like a Promise, i.e. has a "then" function,
7
+ * otherwise returns false.
20
8
  */
21
-
22
- function inspect(value) {
23
- return formatValue(value, []);
24
- }
25
-
26
- function formatValue(value, seenValues) {
27
- switch (_typeof$4(value)) {
28
- case 'string':
29
- return JSON.stringify(value);
30
-
31
- case 'function':
32
- return value.name ? "[function ".concat(value.name, "]") : '[function]';
33
-
34
- case 'object':
35
- if (value === null) {
36
- return 'null';
37
- }
38
-
39
- return formatObjectValue(value, seenValues);
40
-
41
- default:
42
- return String(value);
43
- }
44
- }
45
-
46
- function formatObjectValue(value, previouslySeenValues) {
47
- if (previouslySeenValues.indexOf(value) !== -1) {
48
- return '[Circular]';
49
- }
50
-
51
- var seenValues = [].concat(previouslySeenValues, [value]);
52
- var customInspectFn = getCustomFn(value);
53
-
54
- if (customInspectFn !== undefined) {
55
- var customValue = customInspectFn.call(value); // check for infinite recursion
56
-
57
- if (customValue !== value) {
58
- return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
59
- }
60
- } else if (Array.isArray(value)) {
61
- return formatArray(value, seenValues);
62
- }
63
-
64
- return formatObject(value, seenValues);
65
- }
66
-
67
- function formatObject(object, seenValues) {
68
- var keys = Object.keys(object);
69
-
70
- if (keys.length === 0) {
71
- return '{}';
72
- }
73
-
74
- if (seenValues.length > MAX_RECURSIVE_DEPTH) {
75
- return '[' + getObjectTag(object) + ']';
76
- }
77
-
78
- var properties = keys.map(function (key) {
79
- var value = formatValue(object[key], seenValues);
80
- return key + ': ' + value;
81
- });
82
- return '{ ' + properties.join(', ') + ' }';
83
- }
84
-
85
- function formatArray(array, seenValues) {
86
- if (array.length === 0) {
87
- return '[]';
88
- }
89
-
90
- if (seenValues.length > MAX_RECURSIVE_DEPTH) {
91
- return '[Array]';
92
- }
93
-
94
- var len = Math.min(MAX_ARRAY_LENGTH, array.length);
95
- var remaining = array.length - len;
96
- var items = [];
97
-
98
- for (var i = 0; i < len; ++i) {
99
- items.push(formatValue(array[i], seenValues));
100
- }
101
-
102
- if (remaining === 1) {
103
- items.push('... 1 more item');
104
- } else if (remaining > 1) {
105
- items.push("... ".concat(remaining, " more items"));
106
- }
107
-
108
- return '[' + items.join(', ') + ']';
109
- }
110
-
111
- function getCustomFn(object) {
112
- var customInspectFn = object[String(nodejsCustomInspectSymbol$1)];
113
-
114
- if (typeof customInspectFn === 'function') {
115
- return customInspectFn;
116
- }
117
-
118
- if (typeof object.inspect === 'function') {
119
- return object.inspect;
120
- }
121
- }
122
-
123
- function getObjectTag(object) {
124
- var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
125
-
126
- if (tag === 'Object' && typeof object.constructor === 'function') {
127
- var name = object.constructor.name;
128
-
129
- if (typeof name === 'string' && name !== '') {
130
- return name;
131
- }
132
- }
133
-
134
- return tag;
135
- }
136
-
137
- function devAssert(condition, message) {
138
- var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
139
-
140
- if (!booleanCondition) {
141
- throw new Error(message);
142
- }
9
+ // eslint-disable-next-line no-redeclare
10
+ function isPromise(value) {
11
+ return typeof (value === null || value === void 0 ? void 0 : value.then) === 'function';
143
12
  }
144
13
 
145
- function _typeof$3(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$3 = function _typeof(obj) { return typeof obj; }; } else { _typeof$3 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$3(obj); }
146
- /**
147
- * A replacement for instanceof which includes an error warning when multi-realm
148
- * constructors are detected.
149
- */
150
-
151
- // See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
152
- // See: https://webpack.js.org/guides/production/
153
- var instanceOf = process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
154
- // eslint-disable-next-line no-shadow
155
- function instanceOf(value, constructor) {
156
- return value instanceof constructor;
157
- } : // eslint-disable-next-line no-shadow
158
- function instanceOf(value, constructor) {
159
- if (value instanceof constructor) {
160
- return true;
161
- }
162
-
163
- if (_typeof$3(value) === 'object' && value !== null) {
164
- var _value$constructor;
165
-
166
- var className = constructor.prototype[Symbol.toStringTag];
167
- var valueClassName = // We still need to support constructor's name to detect conflicts with older versions of this library.
168
- Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name;
169
-
170
- if (className === valueClassName) {
171
- var stringifiedValue = inspect(value);
172
- throw new Error("Cannot use ".concat(className, " \"").concat(stringifiedValue, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."));
173
- }
174
- }
175
-
176
- return false;
177
- };
178
-
179
- function _defineProperties$4(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); } }
180
-
181
- function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; }
14
+ function _typeof$4(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$4 = function _typeof(obj) { return typeof obj; }; } else { _typeof$4 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$4(obj); }
182
15
 
183
16
  /**
184
- * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
185
- * optional, but they are useful for clients who store GraphQL documents in source files.
186
- * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
187
- * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
188
- * The `line` and `column` properties in `locationOffset` are 1-indexed.
17
+ * Return true if `value` is object-like. A value is object-like if it's not
18
+ * `null` and has a `typeof` result of "object".
189
19
  */
190
- var Source = /*#__PURE__*/function () {
191
- function Source(body) {
192
- var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GraphQL request';
193
- var locationOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
194
- line: 1,
195
- column: 1
196
- };
197
- typeof body === 'string' || devAssert(0, "Body must be a string. Received: ".concat(inspect(body), "."));
198
- this.body = body;
199
- this.name = name;
200
- this.locationOffset = locationOffset;
201
- this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.');
202
- this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.');
203
- } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
204
-
205
-
206
- _createClass$4(Source, [{
207
- key: SYMBOL_TO_STRING_TAG,
208
- get: function get() {
209
- return 'Source';
210
- }
211
- }]);
20
+ function isObjectLike(value) {
21
+ return _typeof$4(value) == 'object' && value !== null;
22
+ }
212
23
 
213
- return Source;
214
- }();
215
- /**
216
- * Test if the given value is a Source object.
217
- *
218
- * @internal
219
- */
24
+ // In ES2015 (or a polyfilled) environment, this will be Symbol.iterator
25
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
26
+ var SYMBOL_ITERATOR = typeof Symbol === 'function' && Symbol.iterator != null ? Symbol.iterator : '@@iterator'; // In ES2017 (or a polyfilled) environment, this will be Symbol.asyncIterator
220
27
 
221
- // eslint-disable-next-line no-redeclare
222
- function isSource(source) {
223
- return instanceOf(source, Source);
224
- }
28
+ var SYMBOL_TO_STRING_TAG = typeof Symbol === 'function' && Symbol.toStringTag != null ? Symbol.toStringTag : '@@toStringTag';
225
29
 
226
30
  /**
227
31
  * Represents a location in a Source.
@@ -314,144 +118,39 @@ function leftPad(len, str) {
314
118
  return whitespace(len - str.length) + str;
315
119
  }
316
120
 
317
- /**
318
- * The set of allowed kind values for AST nodes.
319
- */
320
- var Kind = Object.freeze({
321
- // Name
322
- NAME: 'Name',
323
- // Document
324
- DOCUMENT: 'Document',
325
- OPERATION_DEFINITION: 'OperationDefinition',
326
- VARIABLE_DEFINITION: 'VariableDefinition',
327
- SELECTION_SET: 'SelectionSet',
328
- FIELD: 'Field',
329
- ARGUMENT: 'Argument',
330
- // Fragments
331
- FRAGMENT_SPREAD: 'FragmentSpread',
332
- INLINE_FRAGMENT: 'InlineFragment',
333
- FRAGMENT_DEFINITION: 'FragmentDefinition',
334
- // Values
335
- VARIABLE: 'Variable',
336
- INT: 'IntValue',
337
- FLOAT: 'FloatValue',
338
- STRING: 'StringValue',
339
- BOOLEAN: 'BooleanValue',
340
- NULL: 'NullValue',
341
- ENUM: 'EnumValue',
342
- LIST: 'ListValue',
343
- OBJECT: 'ObjectValue',
344
- OBJECT_FIELD: 'ObjectField',
345
- // Directives
346
- DIRECTIVE: 'Directive',
347
- // Types
348
- NAMED_TYPE: 'NamedType',
349
- LIST_TYPE: 'ListType',
350
- NON_NULL_TYPE: 'NonNullType',
351
- // Type System Definitions
352
- SCHEMA_DEFINITION: 'SchemaDefinition',
353
- OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition',
354
- // Type Definitions
355
- SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition',
356
- OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition',
357
- FIELD_DEFINITION: 'FieldDefinition',
358
- INPUT_VALUE_DEFINITION: 'InputValueDefinition',
359
- INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition',
360
- UNION_TYPE_DEFINITION: 'UnionTypeDefinition',
361
- ENUM_TYPE_DEFINITION: 'EnumTypeDefinition',
362
- ENUM_VALUE_DEFINITION: 'EnumValueDefinition',
363
- INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition',
364
- // Directive Definitions
365
- DIRECTIVE_DEFINITION: 'DirectiveDefinition',
366
- // Type System Extensions
367
- SCHEMA_EXTENSION: 'SchemaExtension',
368
- // Type Extensions
369
- SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension',
370
- OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension',
371
- INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension',
372
- UNION_TYPE_EXTENSION: 'UnionTypeExtension',
373
- ENUM_TYPE_EXTENSION: 'EnumTypeExtension',
374
- INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension'
375
- });
376
- /**
377
- * The enum type representing the possible kind values of AST nodes.
378
- */
379
-
380
- /**
381
- * An exported enum describing the different kinds of tokens that the
382
- * lexer emits.
383
- */
384
- var TokenKind = Object.freeze({
385
- SOF: '<SOF>',
386
- EOF: '<EOF>',
387
- BANG: '!',
388
- DOLLAR: '$',
389
- AMP: '&',
390
- PAREN_L: '(',
391
- PAREN_R: ')',
392
- SPREAD: '...',
393
- COLON: ':',
394
- EQUALS: '=',
395
- AT: '@',
396
- BRACKET_L: '[',
397
- BRACKET_R: ']',
398
- BRACE_L: '{',
399
- PIPE: '|',
400
- BRACE_R: '}',
401
- NAME: 'Name',
402
- INT: 'Int',
403
- FLOAT: 'Float',
404
- STRING: 'String',
405
- BLOCK_STRING: 'BlockString',
406
- COMMENT: 'Comment'
407
- });
408
- /**
409
- * The enum type representing the token kinds values.
410
- */
411
-
412
- function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
413
-
414
- /**
415
- * Return true if `value` is object-like. A value is object-like if it's not
416
- * `null` and has a `typeof` result of "object".
417
- */
418
- function isObjectLike(value) {
419
- return _typeof$2(value) == 'object' && value !== null;
420
- }
421
-
422
- function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
423
-
424
- function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
425
-
426
- function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty$4(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
427
-
428
- function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
429
-
430
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
431
-
432
- function _defineProperties$3(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); } }
433
-
434
- function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); return Constructor; }
435
-
436
- 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); }
437
-
438
- 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); }; }
439
-
440
- function _possibleConstructorReturn(self, call) { if (call && (_typeof$1(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
441
-
442
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
443
-
444
- function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
445
-
446
- function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
447
-
448
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
449
-
450
- function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
451
-
452
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
453
-
454
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
121
+ function _typeof$3(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$3 = function _typeof(obj) { return typeof obj; }; } else { _typeof$3 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$3(obj); }
122
+
123
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
124
+
125
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty$4(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
126
+
127
+ function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
128
+
129
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
130
+
131
+ function _defineProperties$4(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); } }
132
+
133
+ function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; }
134
+
135
+ 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); }
136
+
137
+ 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); }; }
138
+
139
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof$3(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
140
+
141
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
142
+
143
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
144
+
145
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
146
+
147
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
148
+
149
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
150
+
151
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
152
+
153
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
455
154
  /**
456
155
  * A GraphQLError describes an Error found during the parse, validate, or
457
156
  * execute phases of performing a GraphQL operation. In addition to a message
@@ -605,7 +304,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
605
304
  return _this;
606
305
  }
607
306
 
608
- _createClass$3(GraphQLError, [{
307
+ _createClass$4(GraphQLError, [{
609
308
  key: "toString",
610
309
  value: function toString() {
611
310
  return printError(this);
@@ -661,6 +360,69 @@ function syntaxError(source, position, description) {
661
360
  return new GraphQLError("Syntax Error: ".concat(description), undefined, source, [position]);
662
361
  }
663
362
 
363
+ /**
364
+ * The set of allowed kind values for AST nodes.
365
+ */
366
+ var Kind = Object.freeze({
367
+ // Name
368
+ NAME: 'Name',
369
+ // Document
370
+ DOCUMENT: 'Document',
371
+ OPERATION_DEFINITION: 'OperationDefinition',
372
+ VARIABLE_DEFINITION: 'VariableDefinition',
373
+ SELECTION_SET: 'SelectionSet',
374
+ FIELD: 'Field',
375
+ ARGUMENT: 'Argument',
376
+ // Fragments
377
+ FRAGMENT_SPREAD: 'FragmentSpread',
378
+ INLINE_FRAGMENT: 'InlineFragment',
379
+ FRAGMENT_DEFINITION: 'FragmentDefinition',
380
+ // Values
381
+ VARIABLE: 'Variable',
382
+ INT: 'IntValue',
383
+ FLOAT: 'FloatValue',
384
+ STRING: 'StringValue',
385
+ BOOLEAN: 'BooleanValue',
386
+ NULL: 'NullValue',
387
+ ENUM: 'EnumValue',
388
+ LIST: 'ListValue',
389
+ OBJECT: 'ObjectValue',
390
+ OBJECT_FIELD: 'ObjectField',
391
+ // Directives
392
+ DIRECTIVE: 'Directive',
393
+ // Types
394
+ NAMED_TYPE: 'NamedType',
395
+ LIST_TYPE: 'ListType',
396
+ NON_NULL_TYPE: 'NonNullType',
397
+ // Type System Definitions
398
+ SCHEMA_DEFINITION: 'SchemaDefinition',
399
+ OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition',
400
+ // Type Definitions
401
+ SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition',
402
+ OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition',
403
+ FIELD_DEFINITION: 'FieldDefinition',
404
+ INPUT_VALUE_DEFINITION: 'InputValueDefinition',
405
+ INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition',
406
+ UNION_TYPE_DEFINITION: 'UnionTypeDefinition',
407
+ ENUM_TYPE_DEFINITION: 'EnumTypeDefinition',
408
+ ENUM_VALUE_DEFINITION: 'EnumValueDefinition',
409
+ INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition',
410
+ // Directive Definitions
411
+ DIRECTIVE_DEFINITION: 'DirectiveDefinition',
412
+ // Type System Extensions
413
+ SCHEMA_EXTENSION: 'SchemaExtension',
414
+ // Type Extensions
415
+ SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension',
416
+ OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension',
417
+ INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension',
418
+ UNION_TYPE_EXTENSION: 'UnionTypeExtension',
419
+ ENUM_TYPE_EXTENSION: 'EnumTypeExtension',
420
+ INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension'
421
+ });
422
+ /**
423
+ * The enum type representing the possible kind values of AST nodes.
424
+ */
425
+
664
426
  function invariant(condition, message) {
665
427
  var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
666
428
 
@@ -669,6 +431,10 @@ function invariant(condition, message) {
669
431
  }
670
432
  }
671
433
 
434
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
435
+ var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
436
+ var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
437
+
672
438
  /**
673
439
  * The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
674
440
  */
@@ -801,27 +567,300 @@ function isNode(maybeNode) {
801
567
  */
802
568
 
803
569
  /**
804
- * Produces the value of a block string from its parsed raw value, similar to
805
- * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
806
- *
807
- * This implements the GraphQL spec's BlockStringValue() static algorithm.
808
- *
809
- * @internal
570
+ * An exported enum describing the different kinds of tokens that the
571
+ * lexer emits.
572
+ */
573
+ var TokenKind = Object.freeze({
574
+ SOF: '<SOF>',
575
+ EOF: '<EOF>',
576
+ BANG: '!',
577
+ DOLLAR: '$',
578
+ AMP: '&',
579
+ PAREN_L: '(',
580
+ PAREN_R: ')',
581
+ SPREAD: '...',
582
+ COLON: ':',
583
+ EQUALS: '=',
584
+ AT: '@',
585
+ BRACKET_L: '[',
586
+ BRACKET_R: ']',
587
+ BRACE_L: '{',
588
+ PIPE: '|',
589
+ BRACE_R: '}',
590
+ NAME: 'Name',
591
+ INT: 'Int',
592
+ FLOAT: 'Float',
593
+ STRING: 'String',
594
+ BLOCK_STRING: 'BlockString',
595
+ COMMENT: 'Comment'
596
+ });
597
+ /**
598
+ * The enum type representing the token kinds values.
810
599
  */
811
- function dedentBlockStringValue(rawString) {
812
- // Expand a block string's raw value into independent lines.
813
- var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
814
-
815
- var commonIndent = getBlockStringIndentation(rawString);
816
600
 
817
- if (commonIndent !== 0) {
818
- for (var i = 1; i < lines.length; i++) {
819
- lines[i] = lines[i].slice(commonIndent);
820
- }
821
- } // Remove leading and trailing blank lines.
601
+ function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
602
+ var MAX_ARRAY_LENGTH = 10;
603
+ var MAX_RECURSIVE_DEPTH = 2;
604
+ /**
605
+ * Used to print values in error messages.
606
+ */
822
607
 
608
+ function inspect(value) {
609
+ return formatValue(value, []);
610
+ }
823
611
 
824
- var startLine = 0;
612
+ function formatValue(value, seenValues) {
613
+ switch (_typeof$2(value)) {
614
+ case 'string':
615
+ return JSON.stringify(value);
616
+
617
+ case 'function':
618
+ return value.name ? "[function ".concat(value.name, "]") : '[function]';
619
+
620
+ case 'object':
621
+ if (value === null) {
622
+ return 'null';
623
+ }
624
+
625
+ return formatObjectValue(value, seenValues);
626
+
627
+ default:
628
+ return String(value);
629
+ }
630
+ }
631
+
632
+ function formatObjectValue(value, previouslySeenValues) {
633
+ if (previouslySeenValues.indexOf(value) !== -1) {
634
+ return '[Circular]';
635
+ }
636
+
637
+ var seenValues = [].concat(previouslySeenValues, [value]);
638
+ var customInspectFn = getCustomFn(value);
639
+
640
+ if (customInspectFn !== undefined) {
641
+ var customValue = customInspectFn.call(value); // check for infinite recursion
642
+
643
+ if (customValue !== value) {
644
+ return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
645
+ }
646
+ } else if (Array.isArray(value)) {
647
+ return formatArray(value, seenValues);
648
+ }
649
+
650
+ return formatObject(value, seenValues);
651
+ }
652
+
653
+ function formatObject(object, seenValues) {
654
+ var keys = Object.keys(object);
655
+
656
+ if (keys.length === 0) {
657
+ return '{}';
658
+ }
659
+
660
+ if (seenValues.length > MAX_RECURSIVE_DEPTH) {
661
+ return '[' + getObjectTag(object) + ']';
662
+ }
663
+
664
+ var properties = keys.map(function (key) {
665
+ var value = formatValue(object[key], seenValues);
666
+ return key + ': ' + value;
667
+ });
668
+ return '{ ' + properties.join(', ') + ' }';
669
+ }
670
+
671
+ function formatArray(array, seenValues) {
672
+ if (array.length === 0) {
673
+ return '[]';
674
+ }
675
+
676
+ if (seenValues.length > MAX_RECURSIVE_DEPTH) {
677
+ return '[Array]';
678
+ }
679
+
680
+ var len = Math.min(MAX_ARRAY_LENGTH, array.length);
681
+ var remaining = array.length - len;
682
+ var items = [];
683
+
684
+ for (var i = 0; i < len; ++i) {
685
+ items.push(formatValue(array[i], seenValues));
686
+ }
687
+
688
+ if (remaining === 1) {
689
+ items.push('... 1 more item');
690
+ } else if (remaining > 1) {
691
+ items.push("... ".concat(remaining, " more items"));
692
+ }
693
+
694
+ return '[' + items.join(', ') + ']';
695
+ }
696
+
697
+ function getCustomFn(object) {
698
+ var customInspectFn = object[String(nodejsCustomInspectSymbol$1)];
699
+
700
+ if (typeof customInspectFn === 'function') {
701
+ return customInspectFn;
702
+ }
703
+
704
+ if (typeof object.inspect === 'function') {
705
+ return object.inspect;
706
+ }
707
+ }
708
+
709
+ function getObjectTag(object) {
710
+ var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
711
+
712
+ if (tag === 'Object' && typeof object.constructor === 'function') {
713
+ var name = object.constructor.name;
714
+
715
+ if (typeof name === 'string' && name !== '') {
716
+ return name;
717
+ }
718
+ }
719
+
720
+ return tag;
721
+ }
722
+
723
+ function devAssert(condition, message) {
724
+ var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
725
+
726
+ if (!booleanCondition) {
727
+ throw new Error(message);
728
+ }
729
+ }
730
+
731
+ function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
732
+ /**
733
+ * A replacement for instanceof which includes an error warning when multi-realm
734
+ * constructors are detected.
735
+ */
736
+
737
+ // See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
738
+ // See: https://webpack.js.org/guides/production/
739
+ var instanceOf = process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
740
+ // eslint-disable-next-line no-shadow
741
+ function instanceOf(value, constructor) {
742
+ return value instanceof constructor;
743
+ } : // eslint-disable-next-line no-shadow
744
+ function instanceOf(value, constructor) {
745
+ if (value instanceof constructor) {
746
+ return true;
747
+ }
748
+
749
+ if (_typeof$1(value) === 'object' && value !== null) {
750
+ var _value$constructor;
751
+
752
+ var className = constructor.prototype[Symbol.toStringTag];
753
+ var valueClassName = // We still need to support constructor's name to detect conflicts with older versions of this library.
754
+ Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name;
755
+
756
+ if (className === valueClassName) {
757
+ var stringifiedValue = inspect(value);
758
+ throw new Error("Cannot use ".concat(className, " \"").concat(stringifiedValue, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."));
759
+ }
760
+ }
761
+
762
+ return false;
763
+ };
764
+
765
+ function _defineProperties$3(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); } }
766
+
767
+ function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); return Constructor; }
768
+
769
+ /**
770
+ * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
771
+ * optional, but they are useful for clients who store GraphQL documents in source files.
772
+ * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
773
+ * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
774
+ * The `line` and `column` properties in `locationOffset` are 1-indexed.
775
+ */
776
+ var Source = /*#__PURE__*/function () {
777
+ function Source(body) {
778
+ var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GraphQL request';
779
+ var locationOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
780
+ line: 1,
781
+ column: 1
782
+ };
783
+ typeof body === 'string' || devAssert(0, "Body must be a string. Received: ".concat(inspect(body), "."));
784
+ this.body = body;
785
+ this.name = name;
786
+ this.locationOffset = locationOffset;
787
+ this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.');
788
+ this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.');
789
+ } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
790
+
791
+
792
+ _createClass$3(Source, [{
793
+ key: SYMBOL_TO_STRING_TAG,
794
+ get: function get() {
795
+ return 'Source';
796
+ }
797
+ }]);
798
+
799
+ return Source;
800
+ }();
801
+ /**
802
+ * Test if the given value is a Source object.
803
+ *
804
+ * @internal
805
+ */
806
+
807
+ // eslint-disable-next-line no-redeclare
808
+ function isSource(source) {
809
+ return instanceOf(source, Source);
810
+ }
811
+
812
+ /**
813
+ * The set of allowed directive location values.
814
+ */
815
+ var DirectiveLocation = Object.freeze({
816
+ // Request Definitions
817
+ QUERY: 'QUERY',
818
+ MUTATION: 'MUTATION',
819
+ SUBSCRIPTION: 'SUBSCRIPTION',
820
+ FIELD: 'FIELD',
821
+ FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',
822
+ FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',
823
+ INLINE_FRAGMENT: 'INLINE_FRAGMENT',
824
+ VARIABLE_DEFINITION: 'VARIABLE_DEFINITION',
825
+ // Type System Definitions
826
+ SCHEMA: 'SCHEMA',
827
+ SCALAR: 'SCALAR',
828
+ OBJECT: 'OBJECT',
829
+ FIELD_DEFINITION: 'FIELD_DEFINITION',
830
+ ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',
831
+ INTERFACE: 'INTERFACE',
832
+ UNION: 'UNION',
833
+ ENUM: 'ENUM',
834
+ ENUM_VALUE: 'ENUM_VALUE',
835
+ INPUT_OBJECT: 'INPUT_OBJECT',
836
+ INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'
837
+ });
838
+ /**
839
+ * The enum type representing the directive location values.
840
+ */
841
+
842
+ /**
843
+ * Produces the value of a block string from its parsed raw value, similar to
844
+ * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
845
+ *
846
+ * This implements the GraphQL spec's BlockStringValue() static algorithm.
847
+ *
848
+ * @internal
849
+ */
850
+ function dedentBlockStringValue(rawString) {
851
+ // Expand a block string's raw value into independent lines.
852
+ var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
853
+
854
+ var commonIndent = getBlockStringIndentation(rawString);
855
+
856
+ if (commonIndent !== 0) {
857
+ for (var i = 1; i < lines.length; i++) {
858
+ lines[i] = lines[i].slice(commonIndent);
859
+ }
860
+ } // Remove leading and trailing blank lines.
861
+
862
+
863
+ var startLine = 0;
825
864
 
826
865
  while (startLine < lines.length && isBlank(lines[startLine])) {
827
866
  ++startLine;
@@ -1599,37 +1638,7 @@ function isNameStart(code) {
1599
1638
  }
1600
1639
 
1601
1640
  /**
1602
- * The set of allowed directive location values.
1603
- */
1604
- var DirectiveLocation = Object.freeze({
1605
- // Request Definitions
1606
- QUERY: 'QUERY',
1607
- MUTATION: 'MUTATION',
1608
- SUBSCRIPTION: 'SUBSCRIPTION',
1609
- FIELD: 'FIELD',
1610
- FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',
1611
- FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',
1612
- INLINE_FRAGMENT: 'INLINE_FRAGMENT',
1613
- VARIABLE_DEFINITION: 'VARIABLE_DEFINITION',
1614
- // Type System Definitions
1615
- SCHEMA: 'SCHEMA',
1616
- SCALAR: 'SCALAR',
1617
- OBJECT: 'OBJECT',
1618
- FIELD_DEFINITION: 'FIELD_DEFINITION',
1619
- ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',
1620
- INTERFACE: 'INTERFACE',
1621
- UNION: 'UNION',
1622
- ENUM: 'ENUM',
1623
- ENUM_VALUE: 'ENUM_VALUE',
1624
- INPUT_OBJECT: 'INPUT_OBJECT',
1625
- INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'
1626
- });
1627
- /**
1628
- * The enum type representing the directive location values.
1629
- */
1630
-
1631
- /**
1632
- * Configuration options to control parser behavior
1641
+ * Configuration options to control parser behavior
1633
1642
  */
1634
1643
 
1635
1644
  /**
@@ -3515,738 +3524,713 @@ function getVisitFn(visitor, kind, isLeaving) {
3515
3524
  }
3516
3525
  }
3517
3526
 
3527
+ /* eslint-disable no-redeclare */
3528
+ // $FlowFixMe[name-already-bound]
3529
+ var find = Array.prototype.find ? function (list, predicate) {
3530
+ return Array.prototype.find.call(list, predicate);
3531
+ } : function (list, predicate) {
3532
+ for (var _i2 = 0; _i2 < list.length; _i2++) {
3533
+ var value = list[_i2];
3534
+
3535
+ if (predicate(value)) {
3536
+ return value;
3537
+ }
3538
+ }
3539
+ };
3540
+ var find$1 = find;
3541
+
3542
+ /* eslint-disable no-redeclare */
3543
+ // $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
3544
+ var objectValues = Object.values || function (obj) {
3545
+ return Object.keys(obj).map(function (key) {
3546
+ return obj[key];
3547
+ });
3548
+ };
3549
+
3550
+ var objectValues$1 = objectValues;
3551
+
3518
3552
  /**
3519
- * Converts an AST into a string, using one set of reasonable
3520
- * formatting rules.
3553
+ * Given an arbitrary value, presumably thrown while attempting to execute a
3554
+ * GraphQL operation, produce a new GraphQLError aware of the location in the
3555
+ * document responsible for the original Error.
3521
3556
  */
3522
3557
 
3523
- function print(ast) {
3524
- return visit(ast, {
3525
- leave: printDocASTReducer
3558
+ function locatedError(rawOriginalError, nodes, path) {
3559
+ var _nodes;
3560
+
3561
+ // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.
3562
+ var originalError = rawOriginalError instanceof Error ? rawOriginalError : new Error('Unexpected error value: ' + inspect(rawOriginalError)); // Note: this uses a brand-check to support GraphQL errors originating from other contexts.
3563
+
3564
+ if (Array.isArray(originalError.path)) {
3565
+ return originalError;
3566
+ }
3567
+
3568
+ return new GraphQLError(originalError.message, (_nodes = originalError.nodes) !== null && _nodes !== void 0 ? _nodes : nodes, originalError.source, originalError.positions, path, originalError);
3569
+ }
3570
+
3571
+ var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
3572
+ /**
3573
+ * Returns an Error if a name is invalid.
3574
+ */
3575
+
3576
+ function isValidNameError(name) {
3577
+ typeof name === 'string' || devAssert(0, 'Expected name to be a string.');
3578
+
3579
+ if (name.length > 1 && name[0] === '_' && name[1] === '_') {
3580
+ return new GraphQLError("Name \"".concat(name, "\" must not begin with \"__\", which is reserved by GraphQL introspection."));
3581
+ }
3582
+
3583
+ if (!NAME_RX.test(name)) {
3584
+ return new GraphQLError("Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \"".concat(name, "\" does not."));
3585
+ }
3586
+ }
3587
+
3588
+ /* eslint-disable no-redeclare */
3589
+ // $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
3590
+ var objectEntries = Object.entries || function (obj) {
3591
+ return Object.keys(obj).map(function (key) {
3592
+ return [key, obj[key]];
3526
3593
  });
3594
+ };
3595
+
3596
+ var objectEntries$1 = objectEntries;
3597
+
3598
+ /**
3599
+ * Creates a keyed JS object from an array, given a function to produce the keys
3600
+ * for each value in the array.
3601
+ *
3602
+ * This provides a convenient lookup for the array items if the key function
3603
+ * produces unique results.
3604
+ *
3605
+ * const phoneBook = [
3606
+ * { name: 'Jon', num: '555-1234' },
3607
+ * { name: 'Jenny', num: '867-5309' }
3608
+ * ]
3609
+ *
3610
+ * // { Jon: { name: 'Jon', num: '555-1234' },
3611
+ * // Jenny: { name: 'Jenny', num: '867-5309' } }
3612
+ * const entriesByName = keyMap(
3613
+ * phoneBook,
3614
+ * entry => entry.name
3615
+ * )
3616
+ *
3617
+ * // { name: 'Jenny', num: '857-6309' }
3618
+ * const jennyEntry = entriesByName['Jenny']
3619
+ *
3620
+ */
3621
+ function keyMap(list, keyFn) {
3622
+ return list.reduce(function (map, item) {
3623
+ map[keyFn(item)] = item;
3624
+ return map;
3625
+ }, Object.create(null));
3527
3626
  }
3528
- var MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future
3529
3627
 
3530
- var printDocASTReducer = {
3531
- Name: function Name(node) {
3532
- return node.value;
3533
- },
3534
- Variable: function Variable(node) {
3535
- return '$' + node.name;
3536
- },
3537
- // Document
3538
- Document: function Document(node) {
3539
- return join(node.definitions, '\n\n') + '\n';
3540
- },
3541
- OperationDefinition: function OperationDefinition(node) {
3542
- var op = node.operation;
3543
- var name = node.name;
3544
- var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
3545
- var directives = join(node.directives, ' ');
3546
- var selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use
3547
- // the query short form.
3628
+ /**
3629
+ * Creates an object map with the same keys as `map` and values generated by
3630
+ * running each value of `map` thru `fn`.
3631
+ */
3632
+ function mapValue(map, fn) {
3633
+ var result = Object.create(null);
3548
3634
 
3549
- return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
3550
- },
3551
- VariableDefinition: function VariableDefinition(_ref) {
3552
- var variable = _ref.variable,
3553
- type = _ref.type,
3554
- defaultValue = _ref.defaultValue,
3555
- directives = _ref.directives;
3556
- return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' '));
3557
- },
3558
- SelectionSet: function SelectionSet(_ref2) {
3559
- var selections = _ref2.selections;
3560
- return block(selections);
3561
- },
3562
- Field: function Field(_ref3) {
3563
- var alias = _ref3.alias,
3564
- name = _ref3.name,
3565
- args = _ref3.arguments,
3566
- directives = _ref3.directives,
3567
- selectionSet = _ref3.selectionSet;
3568
- var prefix = wrap('', alias, ': ') + name;
3569
- var argsLine = prefix + wrap('(', join(args, ', '), ')');
3635
+ for (var _i2 = 0, _objectEntries2 = objectEntries$1(map); _i2 < _objectEntries2.length; _i2++) {
3636
+ var _ref2 = _objectEntries2[_i2];
3637
+ var _key = _ref2[0];
3638
+ var _value = _ref2[1];
3639
+ result[_key] = fn(_value, _key);
3640
+ }
3570
3641
 
3571
- if (argsLine.length > MAX_LINE_LENGTH) {
3572
- argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)');
3573
- }
3642
+ return result;
3643
+ }
3574
3644
 
3575
- return join([argsLine, join(directives, ' '), selectionSet], ' ');
3576
- },
3577
- Argument: function Argument(_ref4) {
3578
- var name = _ref4.name,
3579
- value = _ref4.value;
3580
- return name + ': ' + value;
3581
- },
3582
- // Fragments
3583
- FragmentSpread: function FragmentSpread(_ref5) {
3584
- var name = _ref5.name,
3585
- directives = _ref5.directives;
3586
- return '...' + name + wrap(' ', join(directives, ' '));
3587
- },
3588
- InlineFragment: function InlineFragment(_ref6) {
3589
- var typeCondition = _ref6.typeCondition,
3590
- directives = _ref6.directives,
3591
- selectionSet = _ref6.selectionSet;
3592
- return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
3593
- },
3594
- FragmentDefinition: function FragmentDefinition(_ref7) {
3595
- var name = _ref7.name,
3596
- typeCondition = _ref7.typeCondition,
3597
- variableDefinitions = _ref7.variableDefinitions,
3598
- directives = _ref7.directives,
3599
- selectionSet = _ref7.selectionSet;
3600
- return (// Note: fragment variable definitions are experimental and may be changed
3601
- // or removed in the future.
3602
- "fragment ".concat(name).concat(wrap('(', join(variableDefinitions, ', '), ')'), " ") + "on ".concat(typeCondition, " ").concat(wrap('', join(directives, ' '), ' ')) + selectionSet
3603
- );
3604
- },
3605
- // Value
3606
- IntValue: function IntValue(_ref8) {
3607
- var value = _ref8.value;
3608
- return value;
3609
- },
3610
- FloatValue: function FloatValue(_ref9) {
3611
- var value = _ref9.value;
3612
- return value;
3613
- },
3614
- StringValue: function StringValue(_ref10, key) {
3615
- var value = _ref10.value,
3616
- isBlockString = _ref10.block;
3617
- return isBlockString ? printBlockString(value, key === 'description' ? '' : ' ') : JSON.stringify(value);
3618
- },
3619
- BooleanValue: function BooleanValue(_ref11) {
3620
- var value = _ref11.value;
3621
- return value ? 'true' : 'false';
3622
- },
3623
- NullValue: function NullValue() {
3624
- return 'null';
3625
- },
3626
- EnumValue: function EnumValue(_ref12) {
3627
- var value = _ref12.value;
3628
- return value;
3629
- },
3630
- ListValue: function ListValue(_ref13) {
3631
- var values = _ref13.values;
3632
- return '[' + join(values, ', ') + ']';
3633
- },
3634
- ObjectValue: function ObjectValue(_ref14) {
3635
- var fields = _ref14.fields;
3636
- return '{' + join(fields, ', ') + '}';
3637
- },
3638
- ObjectField: function ObjectField(_ref15) {
3639
- var name = _ref15.name,
3640
- value = _ref15.value;
3641
- return name + ': ' + value;
3642
- },
3643
- // Directive
3644
- Directive: function Directive(_ref16) {
3645
- var name = _ref16.name,
3646
- args = _ref16.arguments;
3647
- return '@' + name + wrap('(', join(args, ', '), ')');
3648
- },
3649
- // Type
3650
- NamedType: function NamedType(_ref17) {
3651
- var name = _ref17.name;
3652
- return name;
3653
- },
3654
- ListType: function ListType(_ref18) {
3655
- var type = _ref18.type;
3656
- return '[' + type + ']';
3657
- },
3658
- NonNullType: function NonNullType(_ref19) {
3659
- var type = _ref19.type;
3660
- return type + '!';
3661
- },
3662
- // Type System Definitions
3663
- SchemaDefinition: addDescription(function (_ref20) {
3664
- var directives = _ref20.directives,
3665
- operationTypes = _ref20.operationTypes;
3666
- return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
3667
- }),
3668
- OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
3669
- var operation = _ref21.operation,
3670
- type = _ref21.type;
3671
- return operation + ': ' + type;
3672
- },
3673
- ScalarTypeDefinition: addDescription(function (_ref22) {
3674
- var name = _ref22.name,
3675
- directives = _ref22.directives;
3676
- return join(['scalar', name, join(directives, ' ')], ' ');
3677
- }),
3678
- ObjectTypeDefinition: addDescription(function (_ref23) {
3679
- var name = _ref23.name,
3680
- interfaces = _ref23.interfaces,
3681
- directives = _ref23.directives,
3682
- fields = _ref23.fields;
3683
- return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
3684
- }),
3685
- FieldDefinition: addDescription(function (_ref24) {
3686
- var name = _ref24.name,
3687
- args = _ref24.arguments,
3688
- type = _ref24.type,
3689
- directives = _ref24.directives;
3690
- return name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '));
3691
- }),
3692
- InputValueDefinition: addDescription(function (_ref25) {
3693
- var name = _ref25.name,
3694
- type = _ref25.type,
3695
- defaultValue = _ref25.defaultValue,
3696
- directives = _ref25.directives;
3697
- return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
3698
- }),
3699
- InterfaceTypeDefinition: addDescription(function (_ref26) {
3700
- var name = _ref26.name,
3701
- interfaces = _ref26.interfaces,
3702
- directives = _ref26.directives,
3703
- fields = _ref26.fields;
3704
- return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
3705
- }),
3706
- UnionTypeDefinition: addDescription(function (_ref27) {
3707
- var name = _ref27.name,
3708
- directives = _ref27.directives,
3709
- types = _ref27.types;
3710
- return join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
3711
- }),
3712
- EnumTypeDefinition: addDescription(function (_ref28) {
3713
- var name = _ref28.name,
3714
- directives = _ref28.directives,
3715
- values = _ref28.values;
3716
- return join(['enum', name, join(directives, ' '), block(values)], ' ');
3717
- }),
3718
- EnumValueDefinition: addDescription(function (_ref29) {
3719
- var name = _ref29.name,
3720
- directives = _ref29.directives;
3721
- return join([name, join(directives, ' ')], ' ');
3722
- }),
3723
- InputObjectTypeDefinition: addDescription(function (_ref30) {
3724
- var name = _ref30.name,
3725
- directives = _ref30.directives,
3726
- fields = _ref30.fields;
3727
- return join(['input', name, join(directives, ' '), block(fields)], ' ');
3728
- }),
3729
- DirectiveDefinition: addDescription(function (_ref31) {
3730
- var name = _ref31.name,
3731
- args = _ref31.arguments,
3732
- repeatable = _ref31.repeatable,
3733
- locations = _ref31.locations;
3734
- return 'directive @' + name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + (repeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | ');
3735
- }),
3736
- SchemaExtension: function SchemaExtension(_ref32) {
3737
- var directives = _ref32.directives,
3738
- operationTypes = _ref32.operationTypes;
3739
- return join(['extend schema', join(directives, ' '), block(operationTypes)], ' ');
3740
- },
3741
- ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
3742
- var name = _ref33.name,
3743
- directives = _ref33.directives;
3744
- return join(['extend scalar', name, join(directives, ' ')], ' ');
3745
- },
3746
- ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
3747
- var name = _ref34.name,
3748
- interfaces = _ref34.interfaces,
3749
- directives = _ref34.directives,
3750
- fields = _ref34.fields;
3751
- return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
3752
- },
3753
- InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
3754
- var name = _ref35.name,
3755
- interfaces = _ref35.interfaces,
3756
- directives = _ref35.directives,
3757
- fields = _ref35.fields;
3758
- return join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
3759
- },
3760
- UnionTypeExtension: function UnionTypeExtension(_ref36) {
3761
- var name = _ref36.name,
3762
- directives = _ref36.directives,
3763
- types = _ref36.types;
3764
- return join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
3765
- },
3766
- EnumTypeExtension: function EnumTypeExtension(_ref37) {
3767
- var name = _ref37.name,
3768
- directives = _ref37.directives,
3769
- values = _ref37.values;
3770
- return join(['extend enum', name, join(directives, ' '), block(values)], ' ');
3771
- },
3772
- InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
3773
- var name = _ref38.name,
3774
- directives = _ref38.directives,
3775
- fields = _ref38.fields;
3776
- return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
3645
+ function toObjMap(obj) {
3646
+ /* eslint-enable no-redeclare */
3647
+ if (Object.getPrototypeOf(obj) === null) {
3648
+ return obj;
3777
3649
  }
3778
- };
3779
-
3780
- function addDescription(cb) {
3781
- return function (node) {
3782
- return join([node.description, cb(node)], '\n');
3783
- };
3784
- }
3785
- /**
3786
- * Given maybeArray, print an empty string if it is null or empty, otherwise
3787
- * print all items together separated by separator if provided
3788
- */
3789
3650
 
3651
+ var map = Object.create(null);
3790
3652
 
3791
- function join(maybeArray) {
3792
- var _maybeArray$filter$jo;
3653
+ for (var _i2 = 0, _objectEntries2 = objectEntries$1(obj); _i2 < _objectEntries2.length; _i2++) {
3654
+ var _ref2 = _objectEntries2[_i2];
3655
+ var key = _ref2[0];
3656
+ var value = _ref2[1];
3657
+ map[key] = value;
3658
+ }
3793
3659
 
3794
- var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3795
- return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter(function (x) {
3796
- return x;
3797
- }).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : '';
3660
+ return map;
3798
3661
  }
3662
+
3799
3663
  /**
3800
- * Given array, print each item on its own line, wrapped in an
3801
- * indented "{ }" block.
3664
+ * Creates a keyed JS object from an array, given a function to produce the keys
3665
+ * and a function to produce the values from each item in the array.
3666
+ *
3667
+ * const phoneBook = [
3668
+ * { name: 'Jon', num: '555-1234' },
3669
+ * { name: 'Jenny', num: '867-5309' }
3670
+ * ]
3671
+ *
3672
+ * // { Jon: '555-1234', Jenny: '867-5309' }
3673
+ * const phonesByName = keyValMap(
3674
+ * phoneBook,
3675
+ * entry => entry.name,
3676
+ * entry => entry.num
3677
+ * )
3678
+ *
3802
3679
  */
3803
-
3804
-
3805
- function block(array) {
3806
- return wrap('{\n', indent(join(array, '\n')), '\n}');
3680
+ function keyValMap(list, keyFn, valFn) {
3681
+ return list.reduce(function (map, item) {
3682
+ map[keyFn(item)] = valFn(item);
3683
+ return map;
3684
+ }, Object.create(null));
3807
3685
  }
3686
+
3687
+ var MAX_SUGGESTIONS = 5;
3808
3688
  /**
3809
- * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.
3689
+ * Given [ A, B, C ] return ' Did you mean A, B, or C?'.
3810
3690
  */
3811
3691
 
3692
+ // eslint-disable-next-line no-redeclare
3693
+ function didYouMean(firstArg, secondArg) {
3694
+ var _ref = typeof firstArg === 'string' ? [firstArg, secondArg] : [undefined, firstArg],
3695
+ subMessage = _ref[0],
3696
+ suggestionsArg = _ref[1];
3697
+
3698
+ var message = ' Did you mean ';
3812
3699
 
3813
- function wrap(start, maybeString) {
3814
- var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
3815
- return maybeString != null && maybeString !== '' ? start + maybeString + end : '';
3816
- }
3700
+ if (subMessage) {
3701
+ message += subMessage + ' ';
3702
+ }
3817
3703
 
3818
- function indent(str) {
3819
- return wrap(' ', str.replace(/\n/g, '\n '));
3820
- }
3704
+ var suggestions = suggestionsArg.map(function (x) {
3705
+ return "\"".concat(x, "\"");
3706
+ });
3821
3707
 
3822
- function isMultiline(str) {
3823
- return str.indexOf('\n') !== -1;
3824
- }
3708
+ switch (suggestions.length) {
3709
+ case 0:
3710
+ return '';
3825
3711
 
3826
- function hasMultilineItems(maybeArray) {
3827
- return maybeArray != null && maybeArray.some(isMultiline);
3828
- }
3712
+ case 1:
3713
+ return message + suggestions[0] + '?';
3829
3714
 
3830
- function isExecutableDefinitionNode(node) {
3831
- return node.kind === Kind.OPERATION_DEFINITION || node.kind === Kind.FRAGMENT_DEFINITION;
3832
- }
3833
- function isTypeSystemDefinitionNode(node) {
3834
- return node.kind === Kind.SCHEMA_DEFINITION || isTypeDefinitionNode(node) || node.kind === Kind.DIRECTIVE_DEFINITION;
3835
- }
3836
- function isTypeDefinitionNode(node) {
3837
- return node.kind === Kind.SCALAR_TYPE_DEFINITION || node.kind === Kind.OBJECT_TYPE_DEFINITION || node.kind === Kind.INTERFACE_TYPE_DEFINITION || node.kind === Kind.UNION_TYPE_DEFINITION || node.kind === Kind.ENUM_TYPE_DEFINITION || node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION;
3838
- }
3839
- function isTypeSystemExtensionNode(node) {
3840
- return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);
3841
- }
3842
- function isTypeExtensionNode(node) {
3843
- return node.kind === Kind.SCALAR_TYPE_EXTENSION || node.kind === Kind.OBJECT_TYPE_EXTENSION || node.kind === Kind.INTERFACE_TYPE_EXTENSION || node.kind === Kind.UNION_TYPE_EXTENSION || node.kind === Kind.ENUM_TYPE_EXTENSION || node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION;
3715
+ case 2:
3716
+ return message + suggestions[0] + ' or ' + suggestions[1] + '?';
3717
+ }
3718
+
3719
+ var selected = suggestions.slice(0, MAX_SUGGESTIONS);
3720
+ var lastItem = selected.pop();
3721
+ return message + selected.join(', ') + ', or ' + lastItem + '?';
3844
3722
  }
3845
3723
 
3846
3724
  /**
3847
- * Returns true if the value acts like a Promise, i.e. has a "then" function,
3848
- * otherwise returns false.
3725
+ * Returns the first argument it receives.
3849
3726
  */
3850
- // eslint-disable-next-line no-redeclare
3851
- function isPromise(value) {
3852
- return typeof (value === null || value === void 0 ? void 0 : value.then) === 'function';
3727
+ function identityFunc(x) {
3728
+ return x;
3853
3729
  }
3854
3730
 
3855
- /* eslint-disable no-redeclare */
3856
- // $FlowFixMe[name-already-bound]
3857
- var find = Array.prototype.find ? function (list, predicate) {
3858
- return Array.prototype.find.call(list, predicate);
3859
- } : function (list, predicate) {
3860
- for (var _i2 = 0; _i2 < list.length; _i2++) {
3861
- var value = list[_i2];
3862
-
3863
- if (predicate(value)) {
3864
- return value;
3865
- }
3866
- }
3867
- };
3868
- var find$1 = find;
3731
+ /**
3732
+ * Returns a number indicating whether a reference string comes before, or after,
3733
+ * or is the same as the given string in natural sort order.
3734
+ *
3735
+ * See: https://en.wikipedia.org/wiki/Natural_sort_order
3736
+ *
3737
+ */
3738
+ function naturalCompare(aStr, bStr) {
3739
+ var aIdx = 0;
3740
+ var bIdx = 0;
3869
3741
 
3870
- /* eslint-disable no-redeclare */
3871
- // $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
3872
- var objectValues = Object.values || function (obj) {
3873
- return Object.keys(obj).map(function (key) {
3874
- return obj[key];
3875
- });
3876
- };
3742
+ while (aIdx < aStr.length && bIdx < bStr.length) {
3743
+ var aChar = aStr.charCodeAt(aIdx);
3744
+ var bChar = bStr.charCodeAt(bIdx);
3877
3745
 
3878
- var objectValues$1 = objectValues;
3746
+ if (isDigit(aChar) && isDigit(bChar)) {
3747
+ var aNum = 0;
3879
3748
 
3880
- /**
3881
- * Given an arbitrary value, presumably thrown while attempting to execute a
3882
- * GraphQL operation, produce a new GraphQLError aware of the location in the
3883
- * document responsible for the original Error.
3884
- */
3749
+ do {
3750
+ ++aIdx;
3751
+ aNum = aNum * 10 + aChar - DIGIT_0;
3752
+ aChar = aStr.charCodeAt(aIdx);
3753
+ } while (isDigit(aChar) && aNum > 0);
3885
3754
 
3886
- function locatedError(rawOriginalError, nodes, path) {
3887
- var _nodes;
3755
+ var bNum = 0;
3888
3756
 
3889
- // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.
3890
- var originalError = rawOriginalError instanceof Error ? rawOriginalError : new Error('Unexpected error value: ' + inspect(rawOriginalError)); // Note: this uses a brand-check to support GraphQL errors originating from other contexts.
3757
+ do {
3758
+ ++bIdx;
3759
+ bNum = bNum * 10 + bChar - DIGIT_0;
3760
+ bChar = bStr.charCodeAt(bIdx);
3761
+ } while (isDigit(bChar) && bNum > 0);
3891
3762
 
3892
- if (Array.isArray(originalError.path)) {
3893
- return originalError;
3763
+ if (aNum < bNum) {
3764
+ return -1;
3765
+ }
3766
+
3767
+ if (aNum > bNum) {
3768
+ return 1;
3769
+ }
3770
+ } else {
3771
+ if (aChar < bChar) {
3772
+ return -1;
3773
+ }
3774
+
3775
+ if (aChar > bChar) {
3776
+ return 1;
3777
+ }
3778
+
3779
+ ++aIdx;
3780
+ ++bIdx;
3781
+ }
3894
3782
  }
3895
3783
 
3896
- return new GraphQLError(originalError.message, (_nodes = originalError.nodes) !== null && _nodes !== void 0 ? _nodes : nodes, originalError.source, originalError.positions, path, originalError);
3784
+ return aStr.length - bStr.length;
3785
+ }
3786
+ var DIGIT_0 = 48;
3787
+ var DIGIT_9 = 57;
3788
+
3789
+ function isDigit(code) {
3790
+ return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;
3897
3791
  }
3898
3792
 
3899
- var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
3900
3793
  /**
3901
- * Returns an Error if a name is invalid.
3794
+ * Given an invalid input string and a list of valid options, returns a filtered
3795
+ * list of valid options sorted based on their similarity with the input.
3902
3796
  */
3903
3797
 
3904
- function isValidNameError(name) {
3905
- typeof name === 'string' || devAssert(0, 'Expected name to be a string.');
3798
+ function suggestionList(input, options) {
3799
+ var optionsByDistance = Object.create(null);
3800
+ var lexicalDistance = new LexicalDistance(input);
3801
+ var threshold = Math.floor(input.length * 0.4) + 1;
3906
3802
 
3907
- if (name.length > 1 && name[0] === '_' && name[1] === '_') {
3908
- return new GraphQLError("Name \"".concat(name, "\" must not begin with \"__\", which is reserved by GraphQL introspection."));
3909
- }
3803
+ for (var _i2 = 0; _i2 < options.length; _i2++) {
3804
+ var option = options[_i2];
3805
+ var distance = lexicalDistance.measure(option, threshold);
3910
3806
 
3911
- if (!NAME_RX.test(name)) {
3912
- return new GraphQLError("Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \"".concat(name, "\" does not."));
3807
+ if (distance !== undefined) {
3808
+ optionsByDistance[option] = distance;
3809
+ }
3913
3810
  }
3914
- }
3915
3811
 
3916
- /* eslint-disable no-redeclare */
3917
- // $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
3918
- var objectEntries = Object.entries || function (obj) {
3919
- return Object.keys(obj).map(function (key) {
3920
- return [key, obj[key]];
3812
+ return Object.keys(optionsByDistance).sort(function (a, b) {
3813
+ var distanceDiff = optionsByDistance[a] - optionsByDistance[b];
3814
+ return distanceDiff !== 0 ? distanceDiff : naturalCompare(a, b);
3921
3815
  });
3922
- };
3923
-
3924
- var objectEntries$1 = objectEntries;
3925
-
3816
+ }
3926
3817
  /**
3927
- * Creates a keyed JS object from an array, given a function to produce the keys
3928
- * for each value in the array.
3929
- *
3930
- * This provides a convenient lookup for the array items if the key function
3931
- * produces unique results.
3932
- *
3933
- * const phoneBook = [
3934
- * { name: 'Jon', num: '555-1234' },
3935
- * { name: 'Jenny', num: '867-5309' }
3936
- * ]
3818
+ * Computes the lexical distance between strings A and B.
3937
3819
  *
3938
- * // { Jon: { name: 'Jon', num: '555-1234' },
3939
- * // Jenny: { name: 'Jenny', num: '867-5309' } }
3940
- * const entriesByName = keyMap(
3941
- * phoneBook,
3942
- * entry => entry.name
3943
- * )
3820
+ * The "distance" between two strings is given by counting the minimum number
3821
+ * of edits needed to transform string A into string B. An edit can be an
3822
+ * insertion, deletion, or substitution of a single character, or a swap of two
3823
+ * adjacent characters.
3944
3824
  *
3945
- * // { name: 'Jenny', num: '857-6309' }
3946
- * const jennyEntry = entriesByName['Jenny']
3825
+ * Includes a custom alteration from Damerau-Levenshtein to treat case changes
3826
+ * as a single edit which helps identify mis-cased values with an edit distance
3827
+ * of 1.
3947
3828
  *
3829
+ * This distance can be useful for detecting typos in input or sorting
3948
3830
  */
3949
- function keyMap(list, keyFn) {
3950
- return list.reduce(function (map, item) {
3951
- map[keyFn(item)] = item;
3952
- return map;
3953
- }, Object.create(null));
3954
- }
3955
-
3956
- /**
3957
- * Creates an object map with the same keys as `map` and values generated by
3958
- * running each value of `map` thru `fn`.
3959
- */
3960
- function mapValue(map, fn) {
3961
- var result = Object.create(null);
3962
-
3963
- for (var _i2 = 0, _objectEntries2 = objectEntries$1(map); _i2 < _objectEntries2.length; _i2++) {
3964
- var _ref2 = _objectEntries2[_i2];
3965
- var _key = _ref2[0];
3966
- var _value = _ref2[1];
3967
- result[_key] = fn(_value, _key);
3968
- }
3969
3831
 
3970
- return result;
3971
- }
3972
-
3973
- function toObjMap(obj) {
3974
- /* eslint-enable no-redeclare */
3975
- if (Object.getPrototypeOf(obj) === null) {
3976
- return obj;
3832
+ var LexicalDistance = /*#__PURE__*/function () {
3833
+ function LexicalDistance(input) {
3834
+ this._input = input;
3835
+ this._inputLowerCase = input.toLowerCase();
3836
+ this._inputArray = stringToArray(this._inputLowerCase);
3837
+ this._rows = [new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0)];
3977
3838
  }
3978
3839
 
3979
- var map = Object.create(null);
3840
+ var _proto = LexicalDistance.prototype;
3980
3841
 
3981
- for (var _i2 = 0, _objectEntries2 = objectEntries$1(obj); _i2 < _objectEntries2.length; _i2++) {
3982
- var _ref2 = _objectEntries2[_i2];
3983
- var key = _ref2[0];
3984
- var value = _ref2[1];
3985
- map[key] = value;
3986
- }
3842
+ _proto.measure = function measure(option, threshold) {
3843
+ if (this._input === option) {
3844
+ return 0;
3845
+ }
3987
3846
 
3988
- return map;
3989
- }
3847
+ var optionLowerCase = option.toLowerCase(); // Any case change counts as a single edit
3990
3848
 
3991
- /**
3992
- * Creates a keyed JS object from an array, given a function to produce the keys
3993
- * and a function to produce the values from each item in the array.
3994
- *
3995
- * const phoneBook = [
3996
- * { name: 'Jon', num: '555-1234' },
3997
- * { name: 'Jenny', num: '867-5309' }
3998
- * ]
3999
- *
4000
- * // { Jon: '555-1234', Jenny: '867-5309' }
4001
- * const phonesByName = keyValMap(
4002
- * phoneBook,
4003
- * entry => entry.name,
4004
- * entry => entry.num
4005
- * )
4006
- *
4007
- */
4008
- function keyValMap(list, keyFn, valFn) {
4009
- return list.reduce(function (map, item) {
4010
- map[keyFn(item)] = valFn(item);
4011
- return map;
4012
- }, Object.create(null));
4013
- }
3849
+ if (this._inputLowerCase === optionLowerCase) {
3850
+ return 1;
3851
+ }
4014
3852
 
4015
- var MAX_SUGGESTIONS = 5;
4016
- /**
4017
- * Given [ A, B, C ] return ' Did you mean A, B, or C?'.
4018
- */
3853
+ var a = stringToArray(optionLowerCase);
3854
+ var b = this._inputArray;
4019
3855
 
4020
- // eslint-disable-next-line no-redeclare
4021
- function didYouMean(firstArg, secondArg) {
4022
- var _ref = typeof firstArg === 'string' ? [firstArg, secondArg] : [undefined, firstArg],
4023
- subMessage = _ref[0],
4024
- suggestionsArg = _ref[1];
3856
+ if (a.length < b.length) {
3857
+ var tmp = a;
3858
+ a = b;
3859
+ b = tmp;
3860
+ }
4025
3861
 
4026
- var message = ' Did you mean ';
3862
+ var aLength = a.length;
3863
+ var bLength = b.length;
4027
3864
 
4028
- if (subMessage) {
4029
- message += subMessage + ' ';
4030
- }
3865
+ if (aLength - bLength > threshold) {
3866
+ return undefined;
3867
+ }
4031
3868
 
4032
- var suggestions = suggestionsArg.map(function (x) {
4033
- return "\"".concat(x, "\"");
4034
- });
3869
+ var rows = this._rows;
4035
3870
 
4036
- switch (suggestions.length) {
4037
- case 0:
4038
- return '';
3871
+ for (var j = 0; j <= bLength; j++) {
3872
+ rows[0][j] = j;
3873
+ }
4039
3874
 
4040
- case 1:
4041
- return message + suggestions[0] + '?';
3875
+ for (var i = 1; i <= aLength; i++) {
3876
+ var upRow = rows[(i - 1) % 3];
3877
+ var currentRow = rows[i % 3];
3878
+ var smallestCell = currentRow[0] = i;
4042
3879
 
4043
- case 2:
4044
- return message + suggestions[0] + ' or ' + suggestions[1] + '?';
3880
+ for (var _j = 1; _j <= bLength; _j++) {
3881
+ var cost = a[i - 1] === b[_j - 1] ? 0 : 1;
3882
+ var currentCell = Math.min(upRow[_j] + 1, // delete
3883
+ currentRow[_j - 1] + 1, // insert
3884
+ upRow[_j - 1] + cost // substitute
3885
+ );
3886
+
3887
+ if (i > 1 && _j > 1 && a[i - 1] === b[_j - 2] && a[i - 2] === b[_j - 1]) {
3888
+ // transposition
3889
+ var doubleDiagonalCell = rows[(i - 2) % 3][_j - 2];
3890
+ currentCell = Math.min(currentCell, doubleDiagonalCell + 1);
3891
+ }
3892
+
3893
+ if (currentCell < smallestCell) {
3894
+ smallestCell = currentCell;
3895
+ }
3896
+
3897
+ currentRow[_j] = currentCell;
3898
+ } // Early exit, since distance can't go smaller than smallest element of the previous row.
3899
+
3900
+
3901
+ if (smallestCell > threshold) {
3902
+ return undefined;
3903
+ }
3904
+ }
3905
+
3906
+ var distance = rows[aLength % 3][bLength];
3907
+ return distance <= threshold ? distance : undefined;
3908
+ };
3909
+
3910
+ return LexicalDistance;
3911
+ }();
3912
+
3913
+ function stringToArray(str) {
3914
+ var strLength = str.length;
3915
+ var array = new Array(strLength);
3916
+
3917
+ for (var i = 0; i < strLength; ++i) {
3918
+ array[i] = str.charCodeAt(i);
3919
+ }
3920
+
3921
+ return array;
3922
+ }
3923
+
3924
+ /**
3925
+ * Converts an AST into a string, using one set of reasonable
3926
+ * formatting rules.
3927
+ */
3928
+
3929
+ function print(ast) {
3930
+ return visit(ast, {
3931
+ leave: printDocASTReducer
3932
+ });
3933
+ }
3934
+ var MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future
3935
+
3936
+ var printDocASTReducer = {
3937
+ Name: function Name(node) {
3938
+ return node.value;
3939
+ },
3940
+ Variable: function Variable(node) {
3941
+ return '$' + node.name;
3942
+ },
3943
+ // Document
3944
+ Document: function Document(node) {
3945
+ return join(node.definitions, '\n\n') + '\n';
3946
+ },
3947
+ OperationDefinition: function OperationDefinition(node) {
3948
+ var op = node.operation;
3949
+ var name = node.name;
3950
+ var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
3951
+ var directives = join(node.directives, ' ');
3952
+ var selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use
3953
+ // the query short form.
3954
+
3955
+ return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
3956
+ },
3957
+ VariableDefinition: function VariableDefinition(_ref) {
3958
+ var variable = _ref.variable,
3959
+ type = _ref.type,
3960
+ defaultValue = _ref.defaultValue,
3961
+ directives = _ref.directives;
3962
+ return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' '));
3963
+ },
3964
+ SelectionSet: function SelectionSet(_ref2) {
3965
+ var selections = _ref2.selections;
3966
+ return block(selections);
3967
+ },
3968
+ Field: function Field(_ref3) {
3969
+ var alias = _ref3.alias,
3970
+ name = _ref3.name,
3971
+ args = _ref3.arguments,
3972
+ directives = _ref3.directives,
3973
+ selectionSet = _ref3.selectionSet;
3974
+ var prefix = wrap('', alias, ': ') + name;
3975
+ var argsLine = prefix + wrap('(', join(args, ', '), ')');
3976
+
3977
+ if (argsLine.length > MAX_LINE_LENGTH) {
3978
+ argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)');
3979
+ }
3980
+
3981
+ return join([argsLine, join(directives, ' '), selectionSet], ' ');
3982
+ },
3983
+ Argument: function Argument(_ref4) {
3984
+ var name = _ref4.name,
3985
+ value = _ref4.value;
3986
+ return name + ': ' + value;
3987
+ },
3988
+ // Fragments
3989
+ FragmentSpread: function FragmentSpread(_ref5) {
3990
+ var name = _ref5.name,
3991
+ directives = _ref5.directives;
3992
+ return '...' + name + wrap(' ', join(directives, ' '));
3993
+ },
3994
+ InlineFragment: function InlineFragment(_ref6) {
3995
+ var typeCondition = _ref6.typeCondition,
3996
+ directives = _ref6.directives,
3997
+ selectionSet = _ref6.selectionSet;
3998
+ return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
3999
+ },
4000
+ FragmentDefinition: function FragmentDefinition(_ref7) {
4001
+ var name = _ref7.name,
4002
+ typeCondition = _ref7.typeCondition,
4003
+ variableDefinitions = _ref7.variableDefinitions,
4004
+ directives = _ref7.directives,
4005
+ selectionSet = _ref7.selectionSet;
4006
+ return (// Note: fragment variable definitions are experimental and may be changed
4007
+ // or removed in the future.
4008
+ "fragment ".concat(name).concat(wrap('(', join(variableDefinitions, ', '), ')'), " ") + "on ".concat(typeCondition, " ").concat(wrap('', join(directives, ' '), ' ')) + selectionSet
4009
+ );
4010
+ },
4011
+ // Value
4012
+ IntValue: function IntValue(_ref8) {
4013
+ var value = _ref8.value;
4014
+ return value;
4015
+ },
4016
+ FloatValue: function FloatValue(_ref9) {
4017
+ var value = _ref9.value;
4018
+ return value;
4019
+ },
4020
+ StringValue: function StringValue(_ref10, key) {
4021
+ var value = _ref10.value,
4022
+ isBlockString = _ref10.block;
4023
+ return isBlockString ? printBlockString(value, key === 'description' ? '' : ' ') : JSON.stringify(value);
4024
+ },
4025
+ BooleanValue: function BooleanValue(_ref11) {
4026
+ var value = _ref11.value;
4027
+ return value ? 'true' : 'false';
4028
+ },
4029
+ NullValue: function NullValue() {
4030
+ return 'null';
4031
+ },
4032
+ EnumValue: function EnumValue(_ref12) {
4033
+ var value = _ref12.value;
4034
+ return value;
4035
+ },
4036
+ ListValue: function ListValue(_ref13) {
4037
+ var values = _ref13.values;
4038
+ return '[' + join(values, ', ') + ']';
4039
+ },
4040
+ ObjectValue: function ObjectValue(_ref14) {
4041
+ var fields = _ref14.fields;
4042
+ return '{' + join(fields, ', ') + '}';
4043
+ },
4044
+ ObjectField: function ObjectField(_ref15) {
4045
+ var name = _ref15.name,
4046
+ value = _ref15.value;
4047
+ return name + ': ' + value;
4048
+ },
4049
+ // Directive
4050
+ Directive: function Directive(_ref16) {
4051
+ var name = _ref16.name,
4052
+ args = _ref16.arguments;
4053
+ return '@' + name + wrap('(', join(args, ', '), ')');
4054
+ },
4055
+ // Type
4056
+ NamedType: function NamedType(_ref17) {
4057
+ var name = _ref17.name;
4058
+ return name;
4059
+ },
4060
+ ListType: function ListType(_ref18) {
4061
+ var type = _ref18.type;
4062
+ return '[' + type + ']';
4063
+ },
4064
+ NonNullType: function NonNullType(_ref19) {
4065
+ var type = _ref19.type;
4066
+ return type + '!';
4067
+ },
4068
+ // Type System Definitions
4069
+ SchemaDefinition: addDescription(function (_ref20) {
4070
+ var directives = _ref20.directives,
4071
+ operationTypes = _ref20.operationTypes;
4072
+ return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
4073
+ }),
4074
+ OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
4075
+ var operation = _ref21.operation,
4076
+ type = _ref21.type;
4077
+ return operation + ': ' + type;
4078
+ },
4079
+ ScalarTypeDefinition: addDescription(function (_ref22) {
4080
+ var name = _ref22.name,
4081
+ directives = _ref22.directives;
4082
+ return join(['scalar', name, join(directives, ' ')], ' ');
4083
+ }),
4084
+ ObjectTypeDefinition: addDescription(function (_ref23) {
4085
+ var name = _ref23.name,
4086
+ interfaces = _ref23.interfaces,
4087
+ directives = _ref23.directives,
4088
+ fields = _ref23.fields;
4089
+ return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
4090
+ }),
4091
+ FieldDefinition: addDescription(function (_ref24) {
4092
+ var name = _ref24.name,
4093
+ args = _ref24.arguments,
4094
+ type = _ref24.type,
4095
+ directives = _ref24.directives;
4096
+ return name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '));
4097
+ }),
4098
+ InputValueDefinition: addDescription(function (_ref25) {
4099
+ var name = _ref25.name,
4100
+ type = _ref25.type,
4101
+ defaultValue = _ref25.defaultValue,
4102
+ directives = _ref25.directives;
4103
+ return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
4104
+ }),
4105
+ InterfaceTypeDefinition: addDescription(function (_ref26) {
4106
+ var name = _ref26.name,
4107
+ interfaces = _ref26.interfaces,
4108
+ directives = _ref26.directives,
4109
+ fields = _ref26.fields;
4110
+ return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
4111
+ }),
4112
+ UnionTypeDefinition: addDescription(function (_ref27) {
4113
+ var name = _ref27.name,
4114
+ directives = _ref27.directives,
4115
+ types = _ref27.types;
4116
+ return join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
4117
+ }),
4118
+ EnumTypeDefinition: addDescription(function (_ref28) {
4119
+ var name = _ref28.name,
4120
+ directives = _ref28.directives,
4121
+ values = _ref28.values;
4122
+ return join(['enum', name, join(directives, ' '), block(values)], ' ');
4123
+ }),
4124
+ EnumValueDefinition: addDescription(function (_ref29) {
4125
+ var name = _ref29.name,
4126
+ directives = _ref29.directives;
4127
+ return join([name, join(directives, ' ')], ' ');
4128
+ }),
4129
+ InputObjectTypeDefinition: addDescription(function (_ref30) {
4130
+ var name = _ref30.name,
4131
+ directives = _ref30.directives,
4132
+ fields = _ref30.fields;
4133
+ return join(['input', name, join(directives, ' '), block(fields)], ' ');
4134
+ }),
4135
+ DirectiveDefinition: addDescription(function (_ref31) {
4136
+ var name = _ref31.name,
4137
+ args = _ref31.arguments,
4138
+ repeatable = _ref31.repeatable,
4139
+ locations = _ref31.locations;
4140
+ return 'directive @' + name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + (repeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | ');
4141
+ }),
4142
+ SchemaExtension: function SchemaExtension(_ref32) {
4143
+ var directives = _ref32.directives,
4144
+ operationTypes = _ref32.operationTypes;
4145
+ return join(['extend schema', join(directives, ' '), block(operationTypes)], ' ');
4146
+ },
4147
+ ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
4148
+ var name = _ref33.name,
4149
+ directives = _ref33.directives;
4150
+ return join(['extend scalar', name, join(directives, ' ')], ' ');
4151
+ },
4152
+ ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
4153
+ var name = _ref34.name,
4154
+ interfaces = _ref34.interfaces,
4155
+ directives = _ref34.directives,
4156
+ fields = _ref34.fields;
4157
+ return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
4158
+ },
4159
+ InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
4160
+ var name = _ref35.name,
4161
+ interfaces = _ref35.interfaces,
4162
+ directives = _ref35.directives,
4163
+ fields = _ref35.fields;
4164
+ return join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
4165
+ },
4166
+ UnionTypeExtension: function UnionTypeExtension(_ref36) {
4167
+ var name = _ref36.name,
4168
+ directives = _ref36.directives,
4169
+ types = _ref36.types;
4170
+ return join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
4171
+ },
4172
+ EnumTypeExtension: function EnumTypeExtension(_ref37) {
4173
+ var name = _ref37.name,
4174
+ directives = _ref37.directives,
4175
+ values = _ref37.values;
4176
+ return join(['extend enum', name, join(directives, ' '), block(values)], ' ');
4177
+ },
4178
+ InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
4179
+ var name = _ref38.name,
4180
+ directives = _ref38.directives,
4181
+ fields = _ref38.fields;
4182
+ return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
4045
4183
  }
4184
+ };
4046
4185
 
4047
- var selected = suggestions.slice(0, MAX_SUGGESTIONS);
4048
- var lastItem = selected.pop();
4049
- return message + selected.join(', ') + ', or ' + lastItem + '?';
4050
- }
4051
-
4052
- /**
4053
- * Returns the first argument it receives.
4054
- */
4055
- function identityFunc(x) {
4056
- return x;
4186
+ function addDescription(cb) {
4187
+ return function (node) {
4188
+ return join([node.description, cb(node)], '\n');
4189
+ };
4057
4190
  }
4058
-
4059
4191
  /**
4060
- * Returns a number indicating whether a reference string comes before, or after,
4061
- * or is the same as the given string in natural sort order.
4062
- *
4063
- * See: https://en.wikipedia.org/wiki/Natural_sort_order
4064
- *
4192
+ * Given maybeArray, print an empty string if it is null or empty, otherwise
4193
+ * print all items together separated by separator if provided
4065
4194
  */
4066
- function naturalCompare(aStr, bStr) {
4067
- var aIdx = 0;
4068
- var bIdx = 0;
4069
-
4070
- while (aIdx < aStr.length && bIdx < bStr.length) {
4071
- var aChar = aStr.charCodeAt(aIdx);
4072
- var bChar = bStr.charCodeAt(bIdx);
4073
-
4074
- if (isDigit(aChar) && isDigit(bChar)) {
4075
- var aNum = 0;
4076
-
4077
- do {
4078
- ++aIdx;
4079
- aNum = aNum * 10 + aChar - DIGIT_0;
4080
- aChar = aStr.charCodeAt(aIdx);
4081
- } while (isDigit(aChar) && aNum > 0);
4082
-
4083
- var bNum = 0;
4084
-
4085
- do {
4086
- ++bIdx;
4087
- bNum = bNum * 10 + bChar - DIGIT_0;
4088
- bChar = bStr.charCodeAt(bIdx);
4089
- } while (isDigit(bChar) && bNum > 0);
4090
-
4091
- if (aNum < bNum) {
4092
- return -1;
4093
- }
4094
-
4095
- if (aNum > bNum) {
4096
- return 1;
4097
- }
4098
- } else {
4099
- if (aChar < bChar) {
4100
- return -1;
4101
- }
4102
-
4103
- if (aChar > bChar) {
4104
- return 1;
4105
- }
4106
4195
 
4107
- ++aIdx;
4108
- ++bIdx;
4109
- }
4110
- }
4111
4196
 
4112
- return aStr.length - bStr.length;
4113
- }
4114
- var DIGIT_0 = 48;
4115
- var DIGIT_9 = 57;
4197
+ function join(maybeArray) {
4198
+ var _maybeArray$filter$jo;
4116
4199
 
4117
- function isDigit(code) {
4118
- return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;
4200
+ var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
4201
+ return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter(function (x) {
4202
+ return x;
4203
+ }).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : '';
4119
4204
  }
4120
-
4121
4205
  /**
4122
- * Given an invalid input string and a list of valid options, returns a filtered
4123
- * list of valid options sorted based on their similarity with the input.
4206
+ * Given array, print each item on its own line, wrapped in an
4207
+ * indented "{ }" block.
4124
4208
  */
4125
4209
 
4126
- function suggestionList(input, options) {
4127
- var optionsByDistance = Object.create(null);
4128
- var lexicalDistance = new LexicalDistance(input);
4129
- var threshold = Math.floor(input.length * 0.4) + 1;
4130
-
4131
- for (var _i2 = 0; _i2 < options.length; _i2++) {
4132
- var option = options[_i2];
4133
- var distance = lexicalDistance.measure(option, threshold);
4134
-
4135
- if (distance !== undefined) {
4136
- optionsByDistance[option] = distance;
4137
- }
4138
- }
4139
4210
 
4140
- return Object.keys(optionsByDistance).sort(function (a, b) {
4141
- var distanceDiff = optionsByDistance[a] - optionsByDistance[b];
4142
- return distanceDiff !== 0 ? distanceDiff : naturalCompare(a, b);
4143
- });
4211
+ function block(array) {
4212
+ return wrap('{\n', indent(join(array, '\n')), '\n}');
4144
4213
  }
4145
4214
  /**
4146
- * Computes the lexical distance between strings A and B.
4147
- *
4148
- * The "distance" between two strings is given by counting the minimum number
4149
- * of edits needed to transform string A into string B. An edit can be an
4150
- * insertion, deletion, or substitution of a single character, or a swap of two
4151
- * adjacent characters.
4152
- *
4153
- * Includes a custom alteration from Damerau-Levenshtein to treat case changes
4154
- * as a single edit which helps identify mis-cased values with an edit distance
4155
- * of 1.
4156
- *
4157
- * This distance can be useful for detecting typos in input or sorting
4215
+ * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.
4158
4216
  */
4159
4217
 
4160
- var LexicalDistance = /*#__PURE__*/function () {
4161
- function LexicalDistance(input) {
4162
- this._input = input;
4163
- this._inputLowerCase = input.toLowerCase();
4164
- this._inputArray = stringToArray(this._inputLowerCase);
4165
- this._rows = [new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0)];
4166
- }
4167
-
4168
- var _proto = LexicalDistance.prototype;
4169
-
4170
- _proto.measure = function measure(option, threshold) {
4171
- if (this._input === option) {
4172
- return 0;
4173
- }
4174
-
4175
- var optionLowerCase = option.toLowerCase(); // Any case change counts as a single edit
4176
-
4177
- if (this._inputLowerCase === optionLowerCase) {
4178
- return 1;
4179
- }
4180
-
4181
- var a = stringToArray(optionLowerCase);
4182
- var b = this._inputArray;
4183
-
4184
- if (a.length < b.length) {
4185
- var tmp = a;
4186
- a = b;
4187
- b = tmp;
4188
- }
4189
-
4190
- var aLength = a.length;
4191
- var bLength = b.length;
4192
-
4193
- if (aLength - bLength > threshold) {
4194
- return undefined;
4195
- }
4196
-
4197
- var rows = this._rows;
4198
-
4199
- for (var j = 0; j <= bLength; j++) {
4200
- rows[0][j] = j;
4201
- }
4202
-
4203
- for (var i = 1; i <= aLength; i++) {
4204
- var upRow = rows[(i - 1) % 3];
4205
- var currentRow = rows[i % 3];
4206
- var smallestCell = currentRow[0] = i;
4207
-
4208
- for (var _j = 1; _j <= bLength; _j++) {
4209
- var cost = a[i - 1] === b[_j - 1] ? 0 : 1;
4210
- var currentCell = Math.min(upRow[_j] + 1, // delete
4211
- currentRow[_j - 1] + 1, // insert
4212
- upRow[_j - 1] + cost // substitute
4213
- );
4214
-
4215
- if (i > 1 && _j > 1 && a[i - 1] === b[_j - 2] && a[i - 2] === b[_j - 1]) {
4216
- // transposition
4217
- var doubleDiagonalCell = rows[(i - 2) % 3][_j - 2];
4218
- currentCell = Math.min(currentCell, doubleDiagonalCell + 1);
4219
- }
4220
-
4221
- if (currentCell < smallestCell) {
4222
- smallestCell = currentCell;
4223
- }
4224
-
4225
- currentRow[_j] = currentCell;
4226
- } // Early exit, since distance can't go smaller than smallest element of the previous row.
4227
-
4228
-
4229
- if (smallestCell > threshold) {
4230
- return undefined;
4231
- }
4232
- }
4233
-
4234
- var distance = rows[aLength % 3][bLength];
4235
- return distance <= threshold ? distance : undefined;
4236
- };
4237
4218
 
4238
- return LexicalDistance;
4239
- }();
4219
+ function wrap(start, maybeString) {
4220
+ var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
4221
+ return maybeString != null && maybeString !== '' ? start + maybeString + end : '';
4222
+ }
4240
4223
 
4241
- function stringToArray(str) {
4242
- var strLength = str.length;
4243
- var array = new Array(strLength);
4224
+ function indent(str) {
4225
+ return wrap(' ', str.replace(/\n/g, '\n '));
4226
+ }
4244
4227
 
4245
- for (var i = 0; i < strLength; ++i) {
4246
- array[i] = str.charCodeAt(i);
4247
- }
4228
+ function isMultiline(str) {
4229
+ return str.indexOf('\n') !== -1;
4230
+ }
4248
4231
 
4249
- return array;
4232
+ function hasMultilineItems(maybeArray) {
4233
+ return maybeArray != null && maybeArray.some(isMultiline);
4250
4234
  }
4251
4235
 
4252
4236
  /**
@@ -7560,6 +7544,22 @@ function typeFromAST(schema, typeNode) {
7560
7544
  invariant(0, 'Unexpected type node: ' + inspect(typeNode));
7561
7545
  }
7562
7546
 
7547
+ function isExecutableDefinitionNode(node) {
7548
+ return node.kind === Kind.OPERATION_DEFINITION || node.kind === Kind.FRAGMENT_DEFINITION;
7549
+ }
7550
+ function isTypeSystemDefinitionNode(node) {
7551
+ return node.kind === Kind.SCHEMA_DEFINITION || isTypeDefinitionNode(node) || node.kind === Kind.DIRECTIVE_DEFINITION;
7552
+ }
7553
+ function isTypeDefinitionNode(node) {
7554
+ return node.kind === Kind.SCALAR_TYPE_DEFINITION || node.kind === Kind.OBJECT_TYPE_DEFINITION || node.kind === Kind.INTERFACE_TYPE_DEFINITION || node.kind === Kind.UNION_TYPE_DEFINITION || node.kind === Kind.ENUM_TYPE_DEFINITION || node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION;
7555
+ }
7556
+ function isTypeSystemExtensionNode(node) {
7557
+ return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);
7558
+ }
7559
+ function isTypeExtensionNode(node) {
7560
+ return node.kind === Kind.SCALAR_TYPE_EXTENSION || node.kind === Kind.OBJECT_TYPE_EXTENSION || node.kind === Kind.INTERFACE_TYPE_EXTENSION || node.kind === Kind.UNION_TYPE_EXTENSION || node.kind === Kind.ENUM_TYPE_EXTENSION || node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION;
7561
+ }
7562
+
7563
7563
  /**
7564
7564
  * Executable definitions
7565
7565
  *
@@ -12739,7 +12739,6 @@ const docMap = new Map();
12739
12739
  * As a user shouldn't have access to the Document
12740
12740
  */
12741
12741
  const referenceMap = new WeakMap();
12742
- let addMetaschemaDirectives = false;
12743
12742
  /**
12744
12743
  * Strips characters that are not significant to the validity or execution
12745
12744
  * of a GraphQL document:
@@ -12772,10 +12771,6 @@ function parseDocument(inputString) {
12772
12771
  }
12773
12772
  return null;
12774
12773
  }
12775
- // in-place substitution for removal of legacy and adding metaschema directives
12776
- if (addMetaschemaDirectives) {
12777
- metaschemaMapper(parsedDoc);
12778
- }
12779
12774
  const parsedDocNoLoc = stripLocation(parsedDoc);
12780
12775
  docMap.set(operationKey, parsedDocNoLoc);
12781
12776
  return parsedDocNoLoc;
@@ -12794,9 +12789,12 @@ function insertFragments(doc, fragments) {
12794
12789
  });
12795
12790
  return doc;
12796
12791
  }
12797
- function createReference(document) {
12792
+ function updateReferenceMapWithKnownKey(doc, key) {
12793
+ referenceMap.set(key, doc);
12794
+ }
12795
+ function updateReferenceMapAndGetKey(doc) {
12798
12796
  const key = create(null);
12799
- referenceMap.set(key, document);
12797
+ updateReferenceMapWithKnownKey(doc, key);
12800
12798
  return key;
12801
12799
  }
12802
12800
  /**
@@ -12907,26 +12905,23 @@ function gql(literals, ...subs) {
12907
12905
  return null;
12908
12906
  }
12909
12907
  if (inputSubstitutionFragments.length === 0) {
12910
- return createReference(document);
12908
+ return updateReferenceMapAndGetKey(document);
12911
12909
  }
12912
- return createReference(insertFragments(document, inputSubstitutionFragments));
12913
- }
12914
- /**
12915
- * Enable the parser to add corresponding metaschema directives for backwards compatibility
12916
- */
12917
- function enableAddMetaschemaDirective() {
12918
- addMetaschemaDirectives = true;
12919
- }
12920
- function disableAddMetaschemaDirective() {
12921
- addMetaschemaDirectives = false;
12910
+ return updateReferenceMapAndGetKey(insertFragments(document, inputSubstitutionFragments));
12922
12911
  }
12923
12912
 
12924
- /*
12925
- Deprecated - Remove after existing usages are removed.
12926
- */
12913
+ /**
12914
+ * @deprecated In favor of gql tagged template literal
12915
+ */
12927
12916
  function parseAndVisit(source) {
12928
- const ast = parse(source);
12929
- return transform(ast);
12917
+ const ast = parseDocument(source);
12918
+ const luvioDocumentNode = transform(ast);
12919
+ // In-place substitution of metaschema annotations
12920
+ metaschemaMapper(ast);
12921
+ // Set the AST reference map with LuvioDocumentNode as the key
12922
+ // ASTResolver will resolve it to metaschema mapped AST
12923
+ updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
12924
+ return luvioDocumentNode;
12930
12925
  }
12931
12926
 
12932
12927
  exports.GraphQLScalarType = GraphQLScalarType;
@@ -12935,8 +12930,6 @@ exports.Kind = Kind;
12935
12930
  exports.astResolver = astResolver;
12936
12931
  exports.buildASTSchema = buildASTSchema;
12937
12932
  exports.buildSchema = buildSchema;
12938
- exports.disableAddMetaschemaDirective = disableAddMetaschemaDirective;
12939
- exports.enableAddMetaschemaDirective = enableAddMetaschemaDirective;
12940
12933
  exports.execute = execute;
12941
12934
  exports.getNamedType = getNamedType;
12942
12935
  exports.gql = gql;