@luvio/graphql-parser 0.81.1-238.2 → 0.84.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.
@@ -3858,54 +3858,6 @@ var find = Array.prototype.find ? function (list, predicate) {
3858
3858
  };
3859
3859
  var find$1 = find;
3860
3860
 
3861
- /* eslint-disable no-redeclare */
3862
- // $FlowFixMe[name-already-bound]
3863
- var arrayFrom = Array.from || function (obj, mapFn, thisArg) {
3864
- if (obj == null) {
3865
- throw new TypeError('Array.from requires an array-like object - not null or undefined');
3866
- } // Is Iterable?
3867
-
3868
-
3869
- var iteratorMethod = obj[SYMBOL_ITERATOR];
3870
-
3871
- if (typeof iteratorMethod === 'function') {
3872
- var iterator = iteratorMethod.call(obj);
3873
- var result = [];
3874
- var step;
3875
-
3876
- for (var i = 0; !(step = iterator.next()).done; ++i) {
3877
- result.push(mapFn.call(thisArg, step.value, i)); // Infinite Iterators could cause forEach to run forever.
3878
- // After a very large number of iterations, produce an error.
3879
- // istanbul ignore if (Too big to actually test)
3880
-
3881
- if (i > 9999999) {
3882
- throw new TypeError('Near-infinite iteration.');
3883
- }
3884
- }
3885
-
3886
- return result;
3887
- } // Is Array like?
3888
-
3889
-
3890
- var length = obj.length;
3891
-
3892
- if (typeof length === 'number' && length >= 0 && length % 1 === 0) {
3893
- var _result = [];
3894
-
3895
- for (var _i = 0; _i < length; ++_i) {
3896
- if (Object.prototype.hasOwnProperty.call(obj, _i)) {
3897
- _result.push(mapFn.call(thisArg, obj[_i], _i));
3898
- }
3899
- }
3900
-
3901
- return _result;
3902
- }
3903
-
3904
- return [];
3905
- };
3906
-
3907
- var arrayFrom$1 = arrayFrom;
3908
-
3909
3861
  /* eslint-disable no-redeclare */
3910
3862
  // $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
3911
3863
  var objectValues = Object.values || function (obj) {
@@ -3926,105 +3878,6 @@ var objectEntries = Object.entries || function (obj) {
3926
3878
 
3927
3879
  var objectEntries$1 = objectEntries;
3928
3880
 
3929
- function toObjMap(obj) {
3930
- /* eslint-enable no-redeclare */
3931
- if (Object.getPrototypeOf(obj) === null) {
3932
- return obj;
3933
- }
3934
-
3935
- var map = Object.create(null);
3936
-
3937
- for (var _i2 = 0, _objectEntries2 = objectEntries$1(obj); _i2 < _objectEntries2.length; _i2++) {
3938
- var _ref2 = _objectEntries2[_i2];
3939
- var key = _ref2[0];
3940
- var value = _ref2[1];
3941
- map[key] = value;
3942
- }
3943
-
3944
- return map;
3945
- }
3946
-
3947
- /* eslint-disable no-redeclare */
3948
- // $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
3949
- var isFinitePolyfill = Number.isFinite || function (value) {
3950
- return typeof value === 'number' && isFinite(value);
3951
- };
3952
-
3953
- var isFinite$1 = isFinitePolyfill;
3954
-
3955
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3956
- /**
3957
- * Safer version of `Array.from` that return `null` if value isn't convertible to array.
3958
- * Also protects against Array-like objects without items.
3959
- *
3960
- * @example
3961
- *
3962
- * safeArrayFrom([ 1, 2, 3 ]) // [1, 2, 3]
3963
- * safeArrayFrom('ABC') // null
3964
- * safeArrayFrom({ length: 1 }) // null
3965
- * safeArrayFrom({ length: 1, 0: 'Alpha' }) // ['Alpha']
3966
- * safeArrayFrom({ key: 'value' }) // null
3967
- * safeArrayFrom(new Map()) // []
3968
- *
3969
- */
3970
-
3971
- function safeArrayFrom(collection) {
3972
- var mapFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (item) {
3973
- return item;
3974
- };
3975
-
3976
- if (collection == null || _typeof(collection) !== 'object') {
3977
- return null;
3978
- }
3979
-
3980
- if (Array.isArray(collection)) {
3981
- return collection.map(mapFn);
3982
- } // Is Iterable?
3983
-
3984
-
3985
- var iteratorMethod = collection[SYMBOL_ITERATOR];
3986
-
3987
- if (typeof iteratorMethod === 'function') {
3988
- // $FlowFixMe[incompatible-use]
3989
- var iterator = iteratorMethod.call(collection);
3990
- var result = [];
3991
- var step;
3992
-
3993
- for (var i = 0; !(step = iterator.next()).done; ++i) {
3994
- result.push(mapFn(step.value, i));
3995
- }
3996
-
3997
- return result;
3998
- } // Is Array like?
3999
-
4000
-
4001
- var length = collection.length;
4002
-
4003
- if (typeof length === 'number' && length >= 0 && length % 1 === 0) {
4004
- var _result = [];
4005
-
4006
- for (var _i = 0; _i < length; ++_i) {
4007
- if (!Object.prototype.hasOwnProperty.call(collection, _i)) {
4008
- return null;
4009
- }
4010
-
4011
- _result.push(mapFn(collection[String(_i)], _i));
4012
- }
4013
-
4014
- return _result;
4015
- }
4016
-
4017
- return null;
4018
- }
4019
-
4020
- /* eslint-disable no-redeclare */
4021
- // $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
4022
- var isInteger = Number.isInteger || function (value) {
4023
- return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
4024
- };
4025
-
4026
- var isInteger$1 = isInteger;
4027
-
4028
3881
  /**
4029
3882
  * Creates a keyed JS object from an array, given a function to produce the keys
4030
3883
  * for each value in the array.
@@ -4072,6 +3925,24 @@ function mapValue(map, fn) {
4072
3925
  return result;
4073
3926
  }
4074
3927
 
3928
+ function toObjMap(obj) {
3929
+ /* eslint-enable no-redeclare */
3930
+ if (Object.getPrototypeOf(obj) === null) {
3931
+ return obj;
3932
+ }
3933
+
3934
+ var map = Object.create(null);
3935
+
3936
+ for (var _i2 = 0, _objectEntries2 = objectEntries$1(obj); _i2 < _objectEntries2.length; _i2++) {
3937
+ var _ref2 = _objectEntries2[_i2];
3938
+ var key = _ref2[0];
3939
+ var value = _ref2[1];
3940
+ map[key] = value;
3941
+ }
3942
+
3943
+ return map;
3944
+ }
3945
+
4075
3946
  /**
4076
3947
  * Creates a keyed JS object from an array, given a function to produce the keys
4077
3948
  * and a function to produce the values from each item in the array.
@@ -5355,52 +5226,262 @@ function isRequiredInputField(field) {
5355
5226
  return isNonNullType(field.type) && field.defaultValue === undefined;
5356
5227
  }
5357
5228
 
5358
- // 32-bit signed integer, providing the broadest support across platforms.
5359
- //
5360
- // n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because
5361
- // they are internally represented as IEEE 754 doubles.
5229
+ /**
5230
+ * Provided a type and a super type, return true if the first type is either
5231
+ * equal or a subset of the second super type (covariant).
5232
+ */
5362
5233
 
5363
- var MAX_INT = 2147483647;
5364
- var MIN_INT = -2147483648;
5234
+ function isTypeSubTypeOf(schema, maybeSubType, superType) {
5235
+ // Equivalent type is a valid subtype
5236
+ if (maybeSubType === superType) {
5237
+ return true;
5238
+ } // If superType is non-null, maybeSubType must also be non-null.
5365
5239
 
5366
- function serializeInt(outputValue) {
5367
- var coercedValue = serializeObject(outputValue);
5368
5240
 
5369
- if (typeof coercedValue === 'boolean') {
5370
- return coercedValue ? 1 : 0;
5241
+ if (isNonNullType(superType)) {
5242
+ if (isNonNullType(maybeSubType)) {
5243
+ return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
5244
+ }
5245
+
5246
+ return false;
5371
5247
  }
5372
5248
 
5373
- var num = coercedValue;
5249
+ if (isNonNullType(maybeSubType)) {
5250
+ // If superType is nullable, maybeSubType may be non-null or nullable.
5251
+ return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);
5252
+ } // If superType type is a list, maybeSubType type must also be a list.
5374
5253
 
5375
- if (typeof coercedValue === 'string' && coercedValue !== '') {
5376
- num = Number(coercedValue);
5377
- }
5378
5254
 
5379
- if (!isInteger$1(num)) {
5380
- throw new GraphQLError("Int cannot represent non-integer value: ".concat(inspect(coercedValue)));
5381
- }
5255
+ if (isListType(superType)) {
5256
+ if (isListType(maybeSubType)) {
5257
+ return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
5258
+ }
5382
5259
 
5383
- if (num > MAX_INT || num < MIN_INT) {
5384
- throw new GraphQLError('Int cannot represent non 32-bit signed integer value: ' + inspect(coercedValue));
5260
+ return false;
5385
5261
  }
5386
5262
 
5387
- return num;
5263
+ if (isListType(maybeSubType)) {
5264
+ // If superType is not a list, maybeSubType must also be not a list.
5265
+ return false;
5266
+ } // If superType type is an abstract type, check if it is super type of maybeSubType.
5267
+ // Otherwise, the child type is not a valid subtype of the parent type.
5268
+
5269
+
5270
+ return isAbstractType(superType) && (isInterfaceType(maybeSubType) || isObjectType(maybeSubType)) && schema.isSubType(superType, maybeSubType);
5388
5271
  }
5272
+ /**
5273
+ * Provided two composite types, determine if they "overlap". Two composite
5274
+ * types overlap when the Sets of possible concrete types for each intersect.
5275
+ *
5276
+ * This is often used to determine if a fragment of a given type could possibly
5277
+ * be visited in a context of another type.
5278
+ *
5279
+ * This function is commutative.
5280
+ */
5389
5281
 
5390
- function coerceInt(inputValue) {
5391
- if (!isInteger$1(inputValue)) {
5392
- throw new GraphQLError("Int cannot represent non-integer value: ".concat(inspect(inputValue)));
5282
+ function doTypesOverlap(schema, typeA, typeB) {
5283
+ // Equivalent types overlap
5284
+ if (typeA === typeB) {
5285
+ return true;
5393
5286
  }
5394
5287
 
5395
- if (inputValue > MAX_INT || inputValue < MIN_INT) {
5396
- throw new GraphQLError("Int cannot represent non 32-bit signed integer value: ".concat(inputValue));
5288
+ if (isAbstractType(typeA)) {
5289
+ if (isAbstractType(typeB)) {
5290
+ // If both types are abstract, then determine if there is any intersection
5291
+ // between possible concrete types of each.
5292
+ return schema.getPossibleTypes(typeA).some(function (type) {
5293
+ return schema.isSubType(typeB, type);
5294
+ });
5295
+ } // Determine if the latter type is a possible concrete type of the former.
5296
+
5297
+
5298
+ return schema.isSubType(typeA, typeB);
5397
5299
  }
5398
5300
 
5399
- return inputValue;
5301
+ if (isAbstractType(typeB)) {
5302
+ // Determine if the former type is a possible concrete type of the latter.
5303
+ return schema.isSubType(typeB, typeA);
5304
+ } // Otherwise the types do not overlap.
5305
+
5306
+
5307
+ return false;
5400
5308
  }
5401
5309
 
5402
- var GraphQLInt = new GraphQLScalarType({
5403
- name: 'Int',
5310
+ /* eslint-disable no-redeclare */
5311
+ // $FlowFixMe[name-already-bound]
5312
+ var arrayFrom = Array.from || function (obj, mapFn, thisArg) {
5313
+ if (obj == null) {
5314
+ throw new TypeError('Array.from requires an array-like object - not null or undefined');
5315
+ } // Is Iterable?
5316
+
5317
+
5318
+ var iteratorMethod = obj[SYMBOL_ITERATOR];
5319
+
5320
+ if (typeof iteratorMethod === 'function') {
5321
+ var iterator = iteratorMethod.call(obj);
5322
+ var result = [];
5323
+ var step;
5324
+
5325
+ for (var i = 0; !(step = iterator.next()).done; ++i) {
5326
+ result.push(mapFn.call(thisArg, step.value, i)); // Infinite Iterators could cause forEach to run forever.
5327
+ // After a very large number of iterations, produce an error.
5328
+ // istanbul ignore if (Too big to actually test)
5329
+
5330
+ if (i > 9999999) {
5331
+ throw new TypeError('Near-infinite iteration.');
5332
+ }
5333
+ }
5334
+
5335
+ return result;
5336
+ } // Is Array like?
5337
+
5338
+
5339
+ var length = obj.length;
5340
+
5341
+ if (typeof length === 'number' && length >= 0 && length % 1 === 0) {
5342
+ var _result = [];
5343
+
5344
+ for (var _i = 0; _i < length; ++_i) {
5345
+ if (Object.prototype.hasOwnProperty.call(obj, _i)) {
5346
+ _result.push(mapFn.call(thisArg, obj[_i], _i));
5347
+ }
5348
+ }
5349
+
5350
+ return _result;
5351
+ }
5352
+
5353
+ return [];
5354
+ };
5355
+
5356
+ var arrayFrom$1 = arrayFrom;
5357
+
5358
+ /* eslint-disable no-redeclare */
5359
+ // $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
5360
+ var isFinitePolyfill = Number.isFinite || function (value) {
5361
+ return typeof value === 'number' && isFinite(value);
5362
+ };
5363
+
5364
+ var isFinite$1 = isFinitePolyfill;
5365
+
5366
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
5367
+ /**
5368
+ * Safer version of `Array.from` that return `null` if value isn't convertible to array.
5369
+ * Also protects against Array-like objects without items.
5370
+ *
5371
+ * @example
5372
+ *
5373
+ * safeArrayFrom([ 1, 2, 3 ]) // [1, 2, 3]
5374
+ * safeArrayFrom('ABC') // null
5375
+ * safeArrayFrom({ length: 1 }) // null
5376
+ * safeArrayFrom({ length: 1, 0: 'Alpha' }) // ['Alpha']
5377
+ * safeArrayFrom({ key: 'value' }) // null
5378
+ * safeArrayFrom(new Map()) // []
5379
+ *
5380
+ */
5381
+
5382
+ function safeArrayFrom(collection) {
5383
+ var mapFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (item) {
5384
+ return item;
5385
+ };
5386
+
5387
+ if (collection == null || _typeof(collection) !== 'object') {
5388
+ return null;
5389
+ }
5390
+
5391
+ if (Array.isArray(collection)) {
5392
+ return collection.map(mapFn);
5393
+ } // Is Iterable?
5394
+
5395
+
5396
+ var iteratorMethod = collection[SYMBOL_ITERATOR];
5397
+
5398
+ if (typeof iteratorMethod === 'function') {
5399
+ // $FlowFixMe[incompatible-use]
5400
+ var iterator = iteratorMethod.call(collection);
5401
+ var result = [];
5402
+ var step;
5403
+
5404
+ for (var i = 0; !(step = iterator.next()).done; ++i) {
5405
+ result.push(mapFn(step.value, i));
5406
+ }
5407
+
5408
+ return result;
5409
+ } // Is Array like?
5410
+
5411
+
5412
+ var length = collection.length;
5413
+
5414
+ if (typeof length === 'number' && length >= 0 && length % 1 === 0) {
5415
+ var _result = [];
5416
+
5417
+ for (var _i = 0; _i < length; ++_i) {
5418
+ if (!Object.prototype.hasOwnProperty.call(collection, _i)) {
5419
+ return null;
5420
+ }
5421
+
5422
+ _result.push(mapFn(collection[String(_i)], _i));
5423
+ }
5424
+
5425
+ return _result;
5426
+ }
5427
+
5428
+ return null;
5429
+ }
5430
+
5431
+ /* eslint-disable no-redeclare */
5432
+ // $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
5433
+ var isInteger = Number.isInteger || function (value) {
5434
+ return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
5435
+ };
5436
+
5437
+ var isInteger$1 = isInteger;
5438
+
5439
+ // 32-bit signed integer, providing the broadest support across platforms.
5440
+ //
5441
+ // n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because
5442
+ // they are internally represented as IEEE 754 doubles.
5443
+
5444
+ var MAX_INT = 2147483647;
5445
+ var MIN_INT = -2147483648;
5446
+
5447
+ function serializeInt(outputValue) {
5448
+ var coercedValue = serializeObject(outputValue);
5449
+
5450
+ if (typeof coercedValue === 'boolean') {
5451
+ return coercedValue ? 1 : 0;
5452
+ }
5453
+
5454
+ var num = coercedValue;
5455
+
5456
+ if (typeof coercedValue === 'string' && coercedValue !== '') {
5457
+ num = Number(coercedValue);
5458
+ }
5459
+
5460
+ if (!isInteger$1(num)) {
5461
+ throw new GraphQLError("Int cannot represent non-integer value: ".concat(inspect(coercedValue)));
5462
+ }
5463
+
5464
+ if (num > MAX_INT || num < MIN_INT) {
5465
+ throw new GraphQLError('Int cannot represent non 32-bit signed integer value: ' + inspect(coercedValue));
5466
+ }
5467
+
5468
+ return num;
5469
+ }
5470
+
5471
+ function coerceInt(inputValue) {
5472
+ if (!isInteger$1(inputValue)) {
5473
+ throw new GraphQLError("Int cannot represent non-integer value: ".concat(inspect(inputValue)));
5474
+ }
5475
+
5476
+ if (inputValue > MAX_INT || inputValue < MIN_INT) {
5477
+ throw new GraphQLError("Int cannot represent non 32-bit signed integer value: ".concat(inputValue));
5478
+ }
5479
+
5480
+ return inputValue;
5481
+ }
5482
+
5483
+ var GraphQLInt = new GraphQLScalarType({
5484
+ name: 'Int',
5404
5485
  description: 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.',
5405
5486
  serialize: serializeInt,
5406
5487
  parseValue: coerceInt,
@@ -6831,87 +6912,6 @@ function collectReferencedTypes(type, typeSet) {
6831
6912
  return typeSet;
6832
6913
  }
6833
6914
 
6834
- /**
6835
- * Provided a type and a super type, return true if the first type is either
6836
- * equal or a subset of the second super type (covariant).
6837
- */
6838
-
6839
- function isTypeSubTypeOf(schema, maybeSubType, superType) {
6840
- // Equivalent type is a valid subtype
6841
- if (maybeSubType === superType) {
6842
- return true;
6843
- } // If superType is non-null, maybeSubType must also be non-null.
6844
-
6845
-
6846
- if (isNonNullType(superType)) {
6847
- if (isNonNullType(maybeSubType)) {
6848
- return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
6849
- }
6850
-
6851
- return false;
6852
- }
6853
-
6854
- if (isNonNullType(maybeSubType)) {
6855
- // If superType is nullable, maybeSubType may be non-null or nullable.
6856
- return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);
6857
- } // If superType type is a list, maybeSubType type must also be a list.
6858
-
6859
-
6860
- if (isListType(superType)) {
6861
- if (isListType(maybeSubType)) {
6862
- return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
6863
- }
6864
-
6865
- return false;
6866
- }
6867
-
6868
- if (isListType(maybeSubType)) {
6869
- // If superType is not a list, maybeSubType must also be not a list.
6870
- return false;
6871
- } // If superType type is an abstract type, check if it is super type of maybeSubType.
6872
- // Otherwise, the child type is not a valid subtype of the parent type.
6873
-
6874
-
6875
- return isAbstractType(superType) && (isInterfaceType(maybeSubType) || isObjectType(maybeSubType)) && schema.isSubType(superType, maybeSubType);
6876
- }
6877
- /**
6878
- * Provided two composite types, determine if they "overlap". Two composite
6879
- * types overlap when the Sets of possible concrete types for each intersect.
6880
- *
6881
- * This is often used to determine if a fragment of a given type could possibly
6882
- * be visited in a context of another type.
6883
- *
6884
- * This function is commutative.
6885
- */
6886
-
6887
- function doTypesOverlap(schema, typeA, typeB) {
6888
- // Equivalent types overlap
6889
- if (typeA === typeB) {
6890
- return true;
6891
- }
6892
-
6893
- if (isAbstractType(typeA)) {
6894
- if (isAbstractType(typeB)) {
6895
- // If both types are abstract, then determine if there is any intersection
6896
- // between possible concrete types of each.
6897
- return schema.getPossibleTypes(typeA).some(function (type) {
6898
- return schema.isSubType(typeB, type);
6899
- });
6900
- } // Determine if the latter type is a possible concrete type of the former.
6901
-
6902
-
6903
- return schema.isSubType(typeA, typeB);
6904
- }
6905
-
6906
- if (isAbstractType(typeB)) {
6907
- // Determine if the former type is a possible concrete type of the latter.
6908
- return schema.isSubType(typeB, typeA);
6909
- } // Otherwise the types do not overlap.
6910
-
6911
-
6912
- return false;
6913
- }
6914
-
6915
6915
  /**
6916
6916
  * Given a Schema and an AST node describing a type, return a GraphQLType
6917
6917
  * definition which applies to that type. For example, if provided the parsed
@@ -6945,273 +6945,6 @@ function typeFromAST(schema, typeNode) {
6945
6945
  invariant(0, 'Unexpected type node: ' + inspect(typeNode));
6946
6946
  }
6947
6947
 
6948
- /**
6949
- * Produces a JavaScript value given a GraphQL Value AST.
6950
- *
6951
- * A GraphQL type must be provided, which will be used to interpret different
6952
- * GraphQL Value literals.
6953
- *
6954
- * Returns `undefined` when the value could not be validly coerced according to
6955
- * the provided type.
6956
- *
6957
- * | GraphQL Value | JSON Value |
6958
- * | -------------------- | ------------- |
6959
- * | Input Object | Object |
6960
- * | List | Array |
6961
- * | Boolean | Boolean |
6962
- * | String | String |
6963
- * | Int / Float | Number |
6964
- * | Enum Value | Mixed |
6965
- * | NullValue | null |
6966
- *
6967
- */
6968
-
6969
- function valueFromAST(valueNode, type, variables) {
6970
- if (!valueNode) {
6971
- // When there is no node, then there is also no value.
6972
- // Importantly, this is different from returning the value null.
6973
- return;
6974
- }
6975
-
6976
- if (valueNode.kind === Kind.VARIABLE) {
6977
- var variableName = valueNode.name.value;
6978
-
6979
- if (variables == null || variables[variableName] === undefined) {
6980
- // No valid return value.
6981
- return;
6982
- }
6983
-
6984
- var variableValue = variables[variableName];
6985
-
6986
- if (variableValue === null && isNonNullType(type)) {
6987
- return; // Invalid: intentionally return no value.
6988
- } // Note: This does no further checking that this variable is correct.
6989
- // This assumes that this query has been validated and the variable
6990
- // usage here is of the correct type.
6991
-
6992
-
6993
- return variableValue;
6994
- }
6995
-
6996
- if (isNonNullType(type)) {
6997
- if (valueNode.kind === Kind.NULL) {
6998
- return; // Invalid: intentionally return no value.
6999
- }
7000
-
7001
- return valueFromAST(valueNode, type.ofType, variables);
7002
- }
7003
-
7004
- if (valueNode.kind === Kind.NULL) {
7005
- // This is explicitly returning the value null.
7006
- return null;
7007
- }
7008
-
7009
- if (isListType(type)) {
7010
- var itemType = type.ofType;
7011
-
7012
- if (valueNode.kind === Kind.LIST) {
7013
- var coercedValues = [];
7014
-
7015
- for (var _i2 = 0, _valueNode$values2 = valueNode.values; _i2 < _valueNode$values2.length; _i2++) {
7016
- var itemNode = _valueNode$values2[_i2];
7017
-
7018
- if (isMissingVariable(itemNode, variables)) {
7019
- // If an array contains a missing variable, it is either coerced to
7020
- // null or if the item type is non-null, it considered invalid.
7021
- if (isNonNullType(itemType)) {
7022
- return; // Invalid: intentionally return no value.
7023
- }
7024
-
7025
- coercedValues.push(null);
7026
- } else {
7027
- var itemValue = valueFromAST(itemNode, itemType, variables);
7028
-
7029
- if (itemValue === undefined) {
7030
- return; // Invalid: intentionally return no value.
7031
- }
7032
-
7033
- coercedValues.push(itemValue);
7034
- }
7035
- }
7036
-
7037
- return coercedValues;
7038
- }
7039
-
7040
- var coercedValue = valueFromAST(valueNode, itemType, variables);
7041
-
7042
- if (coercedValue === undefined) {
7043
- return; // Invalid: intentionally return no value.
7044
- }
7045
-
7046
- return [coercedValue];
7047
- }
7048
-
7049
- if (isInputObjectType(type)) {
7050
- if (valueNode.kind !== Kind.OBJECT) {
7051
- return; // Invalid: intentionally return no value.
7052
- }
7053
-
7054
- var coercedObj = Object.create(null);
7055
- var fieldNodes = keyMap(valueNode.fields, function (field) {
7056
- return field.name.value;
7057
- });
7058
-
7059
- for (var _i4 = 0, _objectValues2 = objectValues$1(type.getFields()); _i4 < _objectValues2.length; _i4++) {
7060
- var field = _objectValues2[_i4];
7061
- var fieldNode = fieldNodes[field.name];
7062
-
7063
- if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {
7064
- if (field.defaultValue !== undefined) {
7065
- coercedObj[field.name] = field.defaultValue;
7066
- } else if (isNonNullType(field.type)) {
7067
- return; // Invalid: intentionally return no value.
7068
- }
7069
-
7070
- continue;
7071
- }
7072
-
7073
- var fieldValue = valueFromAST(fieldNode.value, field.type, variables);
7074
-
7075
- if (fieldValue === undefined) {
7076
- return; // Invalid: intentionally return no value.
7077
- }
7078
-
7079
- coercedObj[field.name] = fieldValue;
7080
- }
7081
-
7082
- return coercedObj;
7083
- } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
7084
-
7085
-
7086
- if (isLeafType(type)) {
7087
- // Scalars and Enums fulfill parsing a literal value via parseLiteral().
7088
- // Invalid values represent a failure to parse correctly, in which case
7089
- // no value is returned.
7090
- var result;
7091
-
7092
- try {
7093
- result = type.parseLiteral(valueNode, variables);
7094
- } catch (_error) {
7095
- return; // Invalid: intentionally return no value.
7096
- }
7097
-
7098
- if (result === undefined) {
7099
- return; // Invalid: intentionally return no value.
7100
- }
7101
-
7102
- return result;
7103
- } // istanbul ignore next (Not reachable. All possible input types have been considered)
7104
-
7105
-
7106
- invariant(0, 'Unexpected input type: ' + inspect(type));
7107
- } // Returns true if the provided valueNode is a variable which is not defined
7108
- // in the set of variables.
7109
-
7110
- function isMissingVariable(valueNode, variables) {
7111
- return valueNode.kind === Kind.VARIABLE && (variables == null || variables[valueNode.name.value] === undefined);
7112
- }
7113
-
7114
- /**
7115
- * Prepares an object map of argument values given a list of argument
7116
- * definitions and list of argument AST nodes.
7117
- *
7118
- * Note: The returned value is a plain Object with a prototype, since it is
7119
- * exposed to user code. Care should be taken to not pull values from the
7120
- * Object prototype.
7121
- *
7122
- * @internal
7123
- */
7124
-
7125
-
7126
- function getArgumentValues(def, node, variableValues) {
7127
- var _node$arguments;
7128
-
7129
- var coercedValues = {}; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
7130
-
7131
- var argumentNodes = (_node$arguments = node.arguments) !== null && _node$arguments !== void 0 ? _node$arguments : [];
7132
- var argNodeMap = keyMap(argumentNodes, function (arg) {
7133
- return arg.name.value;
7134
- });
7135
-
7136
- for (var _i4 = 0, _def$args2 = def.args; _i4 < _def$args2.length; _i4++) {
7137
- var argDef = _def$args2[_i4];
7138
- var name = argDef.name;
7139
- var argType = argDef.type;
7140
- var argumentNode = argNodeMap[name];
7141
-
7142
- if (!argumentNode) {
7143
- if (argDef.defaultValue !== undefined) {
7144
- coercedValues[name] = argDef.defaultValue;
7145
- } else if (isNonNullType(argType)) {
7146
- throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + 'was not provided.', node);
7147
- }
7148
-
7149
- continue;
7150
- }
7151
-
7152
- var valueNode = argumentNode.value;
7153
- var isNull = valueNode.kind === Kind.NULL;
7154
-
7155
- if (valueNode.kind === Kind.VARIABLE) {
7156
- var variableName = valueNode.name.value;
7157
-
7158
- if (variableValues == null || !hasOwnProperty(variableValues, variableName)) {
7159
- if (argDef.defaultValue !== undefined) {
7160
- coercedValues[name] = argDef.defaultValue;
7161
- } else if (isNonNullType(argType)) {
7162
- throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + "was provided the variable \"$".concat(variableName, "\" which was not provided a runtime value."), valueNode);
7163
- }
7164
-
7165
- continue;
7166
- }
7167
-
7168
- isNull = variableValues[variableName] == null;
7169
- }
7170
-
7171
- if (isNull && isNonNullType(argType)) {
7172
- throw new GraphQLError("Argument \"".concat(name, "\" of non-null type \"").concat(inspect(argType), "\" ") + 'must not be null.', valueNode);
7173
- }
7174
-
7175
- var coercedValue = valueFromAST(valueNode, argType, variableValues);
7176
-
7177
- if (coercedValue === undefined) {
7178
- // Note: ValuesOfCorrectTypeRule validation should catch this before
7179
- // execution. This is a runtime check to ensure execution does not
7180
- // continue with an invalid argument value.
7181
- throw new GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat(print(valueNode), "."), valueNode);
7182
- }
7183
-
7184
- coercedValues[name] = coercedValue;
7185
- }
7186
-
7187
- return coercedValues;
7188
- }
7189
- /**
7190
- * Prepares an object map of argument values given a directive definition
7191
- * and a AST node which may contain directives. Optionally also accepts a map
7192
- * of variable values.
7193
- *
7194
- * If the directive does not exist on the node, returns undefined.
7195
- *
7196
- * Note: The returned value is a plain Object with a prototype, since it is
7197
- * exposed to user code. Care should be taken to not pull values from the
7198
- * Object prototype.
7199
- */
7200
-
7201
- function getDirectiveValues(directiveDef, node, variableValues) {
7202
- var directiveNode = node.directives && find$1(node.directives, function (directive) {
7203
- return directive.name.value === directiveDef.name;
7204
- });
7205
-
7206
- if (directiveNode) {
7207
- return getArgumentValues(directiveDef, directiveNode, variableValues);
7208
- }
7209
- }
7210
-
7211
- function hasOwnProperty(obj, prop) {
7212
- return Object.prototype.hasOwnProperty.call(obj, prop);
7213
- }
7214
-
7215
6948
  /**
7216
6949
  * Executable definitions
7217
6950
  *
@@ -9413,147 +9146,414 @@ var ASTValidationContext = /*#__PURE__*/function () {
9413
9146
  this._onError = onError;
9414
9147
  }
9415
9148
 
9416
- var _proto = ASTValidationContext.prototype;
9149
+ var _proto = ASTValidationContext.prototype;
9150
+
9151
+ _proto.reportError = function reportError(error) {
9152
+ this._onError(error);
9153
+ };
9154
+
9155
+ _proto.getDocument = function getDocument() {
9156
+ return this._ast;
9157
+ };
9158
+
9159
+ _proto.getFragment = function getFragment(name) {
9160
+ var fragments = this._fragments;
9161
+
9162
+ if (!fragments) {
9163
+ this._fragments = fragments = this.getDocument().definitions.reduce(function (frags, statement) {
9164
+ if (statement.kind === Kind.FRAGMENT_DEFINITION) {
9165
+ frags[statement.name.value] = statement;
9166
+ }
9167
+
9168
+ return frags;
9169
+ }, Object.create(null));
9170
+ }
9171
+
9172
+ return fragments[name];
9173
+ };
9174
+
9175
+ _proto.getFragmentSpreads = function getFragmentSpreads(node) {
9176
+ var spreads = this._fragmentSpreads.get(node);
9177
+
9178
+ if (!spreads) {
9179
+ spreads = [];
9180
+ var setsToVisit = [node];
9181
+
9182
+ while (setsToVisit.length !== 0) {
9183
+ var set = setsToVisit.pop();
9184
+
9185
+ for (var _i2 = 0, _set$selections2 = set.selections; _i2 < _set$selections2.length; _i2++) {
9186
+ var selection = _set$selections2[_i2];
9187
+
9188
+ if (selection.kind === Kind.FRAGMENT_SPREAD) {
9189
+ spreads.push(selection);
9190
+ } else if (selection.selectionSet) {
9191
+ setsToVisit.push(selection.selectionSet);
9192
+ }
9193
+ }
9194
+ }
9195
+
9196
+ this._fragmentSpreads.set(node, spreads);
9197
+ }
9198
+
9199
+ return spreads;
9200
+ };
9201
+
9202
+ _proto.getRecursivelyReferencedFragments = function getRecursivelyReferencedFragments(operation) {
9203
+ var fragments = this._recursivelyReferencedFragments.get(operation);
9204
+
9205
+ if (!fragments) {
9206
+ fragments = [];
9207
+ var collectedNames = Object.create(null);
9208
+ var nodesToVisit = [operation.selectionSet];
9209
+
9210
+ while (nodesToVisit.length !== 0) {
9211
+ var node = nodesToVisit.pop();
9212
+
9213
+ for (var _i4 = 0, _this$getFragmentSpre2 = this.getFragmentSpreads(node); _i4 < _this$getFragmentSpre2.length; _i4++) {
9214
+ var spread = _this$getFragmentSpre2[_i4];
9215
+ var fragName = spread.name.value;
9216
+
9217
+ if (collectedNames[fragName] !== true) {
9218
+ collectedNames[fragName] = true;
9219
+ var fragment = this.getFragment(fragName);
9220
+
9221
+ if (fragment) {
9222
+ fragments.push(fragment);
9223
+ nodesToVisit.push(fragment.selectionSet);
9224
+ }
9225
+ }
9226
+ }
9227
+ }
9228
+
9229
+ this._recursivelyReferencedFragments.set(operation, fragments);
9230
+ }
9231
+
9232
+ return fragments;
9233
+ };
9234
+
9235
+ return ASTValidationContext;
9236
+ }();
9237
+ var SDLValidationContext = /*#__PURE__*/function (_ASTValidationContext) {
9238
+ _inheritsLoose(SDLValidationContext, _ASTValidationContext);
9239
+
9240
+ function SDLValidationContext(ast, schema, onError) {
9241
+ var _this;
9242
+
9243
+ _this = _ASTValidationContext.call(this, ast, onError) || this;
9244
+ _this._schema = schema;
9245
+ return _this;
9246
+ }
9247
+
9248
+ var _proto2 = SDLValidationContext.prototype;
9249
+
9250
+ _proto2.getSchema = function getSchema() {
9251
+ return this._schema;
9252
+ };
9253
+
9254
+ return SDLValidationContext;
9255
+ }(ASTValidationContext);
9256
+
9257
+ /**
9258
+ * @internal
9259
+ */
9260
+
9261
+ function validateSDL(documentAST, schemaToExtend) {
9262
+ var rules = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : specifiedSDLRules;
9263
+ var errors = [];
9264
+ var context = new SDLValidationContext(documentAST, schemaToExtend, function (error) {
9265
+ errors.push(error);
9266
+ });
9267
+ var visitors = rules.map(function (rule) {
9268
+ return rule(context);
9269
+ });
9270
+ visit(documentAST, visitInParallel(visitors));
9271
+ return errors;
9272
+ }
9273
+ /**
9274
+ * Utility function which asserts a SDL document is valid by throwing an error
9275
+ * if it is invalid.
9276
+ *
9277
+ * @internal
9278
+ */
9279
+
9280
+ function assertValidSDL(documentAST) {
9281
+ var errors = validateSDL(documentAST);
9282
+
9283
+ if (errors.length !== 0) {
9284
+ throw new Error(errors.map(function (error) {
9285
+ return error.message;
9286
+ }).join('\n\n'));
9287
+ }
9288
+ }
9289
+
9290
+ /**
9291
+ * Produces a JavaScript value given a GraphQL Value AST.
9292
+ *
9293
+ * A GraphQL type must be provided, which will be used to interpret different
9294
+ * GraphQL Value literals.
9295
+ *
9296
+ * Returns `undefined` when the value could not be validly coerced according to
9297
+ * the provided type.
9298
+ *
9299
+ * | GraphQL Value | JSON Value |
9300
+ * | -------------------- | ------------- |
9301
+ * | Input Object | Object |
9302
+ * | List | Array |
9303
+ * | Boolean | Boolean |
9304
+ * | String | String |
9305
+ * | Int / Float | Number |
9306
+ * | Enum Value | Mixed |
9307
+ * | NullValue | null |
9308
+ *
9309
+ */
9310
+
9311
+ function valueFromAST(valueNode, type, variables) {
9312
+ if (!valueNode) {
9313
+ // When there is no node, then there is also no value.
9314
+ // Importantly, this is different from returning the value null.
9315
+ return;
9316
+ }
9317
+
9318
+ if (valueNode.kind === Kind.VARIABLE) {
9319
+ var variableName = valueNode.name.value;
9320
+
9321
+ if (variables == null || variables[variableName] === undefined) {
9322
+ // No valid return value.
9323
+ return;
9324
+ }
9325
+
9326
+ var variableValue = variables[variableName];
9327
+
9328
+ if (variableValue === null && isNonNullType(type)) {
9329
+ return; // Invalid: intentionally return no value.
9330
+ } // Note: This does no further checking that this variable is correct.
9331
+ // This assumes that this query has been validated and the variable
9332
+ // usage here is of the correct type.
9333
+
9334
+
9335
+ return variableValue;
9336
+ }
9337
+
9338
+ if (isNonNullType(type)) {
9339
+ if (valueNode.kind === Kind.NULL) {
9340
+ return; // Invalid: intentionally return no value.
9341
+ }
9342
+
9343
+ return valueFromAST(valueNode, type.ofType, variables);
9344
+ }
9345
+
9346
+ if (valueNode.kind === Kind.NULL) {
9347
+ // This is explicitly returning the value null.
9348
+ return null;
9349
+ }
9350
+
9351
+ if (isListType(type)) {
9352
+ var itemType = type.ofType;
9353
+
9354
+ if (valueNode.kind === Kind.LIST) {
9355
+ var coercedValues = [];
9356
+
9357
+ for (var _i2 = 0, _valueNode$values2 = valueNode.values; _i2 < _valueNode$values2.length; _i2++) {
9358
+ var itemNode = _valueNode$values2[_i2];
9359
+
9360
+ if (isMissingVariable(itemNode, variables)) {
9361
+ // If an array contains a missing variable, it is either coerced to
9362
+ // null or if the item type is non-null, it considered invalid.
9363
+ if (isNonNullType(itemType)) {
9364
+ return; // Invalid: intentionally return no value.
9365
+ }
9366
+
9367
+ coercedValues.push(null);
9368
+ } else {
9369
+ var itemValue = valueFromAST(itemNode, itemType, variables);
9370
+
9371
+ if (itemValue === undefined) {
9372
+ return; // Invalid: intentionally return no value.
9373
+ }
9374
+
9375
+ coercedValues.push(itemValue);
9376
+ }
9377
+ }
9378
+
9379
+ return coercedValues;
9380
+ }
9381
+
9382
+ var coercedValue = valueFromAST(valueNode, itemType, variables);
9383
+
9384
+ if (coercedValue === undefined) {
9385
+ return; // Invalid: intentionally return no value.
9386
+ }
9387
+
9388
+ return [coercedValue];
9389
+ }
9390
+
9391
+ if (isInputObjectType(type)) {
9392
+ if (valueNode.kind !== Kind.OBJECT) {
9393
+ return; // Invalid: intentionally return no value.
9394
+ }
9395
+
9396
+ var coercedObj = Object.create(null);
9397
+ var fieldNodes = keyMap(valueNode.fields, function (field) {
9398
+ return field.name.value;
9399
+ });
9400
+
9401
+ for (var _i4 = 0, _objectValues2 = objectValues$1(type.getFields()); _i4 < _objectValues2.length; _i4++) {
9402
+ var field = _objectValues2[_i4];
9403
+ var fieldNode = fieldNodes[field.name];
9417
9404
 
9418
- _proto.reportError = function reportError(error) {
9419
- this._onError(error);
9420
- };
9405
+ if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {
9406
+ if (field.defaultValue !== undefined) {
9407
+ coercedObj[field.name] = field.defaultValue;
9408
+ } else if (isNonNullType(field.type)) {
9409
+ return; // Invalid: intentionally return no value.
9410
+ }
9421
9411
 
9422
- _proto.getDocument = function getDocument() {
9423
- return this._ast;
9424
- };
9412
+ continue;
9413
+ }
9425
9414
 
9426
- _proto.getFragment = function getFragment(name) {
9427
- var fragments = this._fragments;
9415
+ var fieldValue = valueFromAST(fieldNode.value, field.type, variables);
9428
9416
 
9429
- if (!fragments) {
9430
- this._fragments = fragments = this.getDocument().definitions.reduce(function (frags, statement) {
9431
- if (statement.kind === Kind.FRAGMENT_DEFINITION) {
9432
- frags[statement.name.value] = statement;
9433
- }
9417
+ if (fieldValue === undefined) {
9418
+ return; // Invalid: intentionally return no value.
9419
+ }
9434
9420
 
9435
- return frags;
9436
- }, Object.create(null));
9421
+ coercedObj[field.name] = fieldValue;
9437
9422
  }
9438
9423
 
9439
- return fragments[name];
9440
- };
9424
+ return coercedObj;
9425
+ } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
9441
9426
 
9442
- _proto.getFragmentSpreads = function getFragmentSpreads(node) {
9443
- var spreads = this._fragmentSpreads.get(node);
9444
9427
 
9445
- if (!spreads) {
9446
- spreads = [];
9447
- var setsToVisit = [node];
9428
+ if (isLeafType(type)) {
9429
+ // Scalars and Enums fulfill parsing a literal value via parseLiteral().
9430
+ // Invalid values represent a failure to parse correctly, in which case
9431
+ // no value is returned.
9432
+ var result;
9448
9433
 
9449
- while (setsToVisit.length !== 0) {
9450
- var set = setsToVisit.pop();
9434
+ try {
9435
+ result = type.parseLiteral(valueNode, variables);
9436
+ } catch (_error) {
9437
+ return; // Invalid: intentionally return no value.
9438
+ }
9451
9439
 
9452
- for (var _i2 = 0, _set$selections2 = set.selections; _i2 < _set$selections2.length; _i2++) {
9453
- var selection = _set$selections2[_i2];
9440
+ if (result === undefined) {
9441
+ return; // Invalid: intentionally return no value.
9442
+ }
9454
9443
 
9455
- if (selection.kind === Kind.FRAGMENT_SPREAD) {
9456
- spreads.push(selection);
9457
- } else if (selection.selectionSet) {
9458
- setsToVisit.push(selection.selectionSet);
9459
- }
9460
- }
9461
- }
9444
+ return result;
9445
+ } // istanbul ignore next (Not reachable. All possible input types have been considered)
9462
9446
 
9463
- this._fragmentSpreads.set(node, spreads);
9464
- }
9465
9447
 
9466
- return spreads;
9467
- };
9448
+ invariant(0, 'Unexpected input type: ' + inspect(type));
9449
+ } // Returns true if the provided valueNode is a variable which is not defined
9450
+ // in the set of variables.
9468
9451
 
9469
- _proto.getRecursivelyReferencedFragments = function getRecursivelyReferencedFragments(operation) {
9470
- var fragments = this._recursivelyReferencedFragments.get(operation);
9452
+ function isMissingVariable(valueNode, variables) {
9453
+ return valueNode.kind === Kind.VARIABLE && (variables == null || variables[valueNode.name.value] === undefined);
9454
+ }
9471
9455
 
9472
- if (!fragments) {
9473
- fragments = [];
9474
- var collectedNames = Object.create(null);
9475
- var nodesToVisit = [operation.selectionSet];
9456
+ /**
9457
+ * Prepares an object map of argument values given a list of argument
9458
+ * definitions and list of argument AST nodes.
9459
+ *
9460
+ * Note: The returned value is a plain Object with a prototype, since it is
9461
+ * exposed to user code. Care should be taken to not pull values from the
9462
+ * Object prototype.
9463
+ *
9464
+ * @internal
9465
+ */
9476
9466
 
9477
- while (nodesToVisit.length !== 0) {
9478
- var node = nodesToVisit.pop();
9479
9467
 
9480
- for (var _i4 = 0, _this$getFragmentSpre2 = this.getFragmentSpreads(node); _i4 < _this$getFragmentSpre2.length; _i4++) {
9481
- var spread = _this$getFragmentSpre2[_i4];
9482
- var fragName = spread.name.value;
9468
+ function getArgumentValues(def, node, variableValues) {
9469
+ var _node$arguments;
9483
9470
 
9484
- if (collectedNames[fragName] !== true) {
9485
- collectedNames[fragName] = true;
9486
- var fragment = this.getFragment(fragName);
9471
+ var coercedValues = {}; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
9487
9472
 
9488
- if (fragment) {
9489
- fragments.push(fragment);
9490
- nodesToVisit.push(fragment.selectionSet);
9491
- }
9492
- }
9493
- }
9473
+ var argumentNodes = (_node$arguments = node.arguments) !== null && _node$arguments !== void 0 ? _node$arguments : [];
9474
+ var argNodeMap = keyMap(argumentNodes, function (arg) {
9475
+ return arg.name.value;
9476
+ });
9477
+
9478
+ for (var _i4 = 0, _def$args2 = def.args; _i4 < _def$args2.length; _i4++) {
9479
+ var argDef = _def$args2[_i4];
9480
+ var name = argDef.name;
9481
+ var argType = argDef.type;
9482
+ var argumentNode = argNodeMap[name];
9483
+
9484
+ if (!argumentNode) {
9485
+ if (argDef.defaultValue !== undefined) {
9486
+ coercedValues[name] = argDef.defaultValue;
9487
+ } else if (isNonNullType(argType)) {
9488
+ throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + 'was not provided.', node);
9494
9489
  }
9495
9490
 
9496
- this._recursivelyReferencedFragments.set(operation, fragments);
9491
+ continue;
9497
9492
  }
9498
9493
 
9499
- return fragments;
9500
- };
9494
+ var valueNode = argumentNode.value;
9495
+ var isNull = valueNode.kind === Kind.NULL;
9501
9496
 
9502
- return ASTValidationContext;
9503
- }();
9504
- var SDLValidationContext = /*#__PURE__*/function (_ASTValidationContext) {
9505
- _inheritsLoose(SDLValidationContext, _ASTValidationContext);
9497
+ if (valueNode.kind === Kind.VARIABLE) {
9498
+ var variableName = valueNode.name.value;
9506
9499
 
9507
- function SDLValidationContext(ast, schema, onError) {
9508
- var _this;
9500
+ if (variableValues == null || !hasOwnProperty(variableValues, variableName)) {
9501
+ if (argDef.defaultValue !== undefined) {
9502
+ coercedValues[name] = argDef.defaultValue;
9503
+ } else if (isNonNullType(argType)) {
9504
+ throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + "was provided the variable \"$".concat(variableName, "\" which was not provided a runtime value."), valueNode);
9505
+ }
9509
9506
 
9510
- _this = _ASTValidationContext.call(this, ast, onError) || this;
9511
- _this._schema = schema;
9512
- return _this;
9513
- }
9507
+ continue;
9508
+ }
9514
9509
 
9515
- var _proto2 = SDLValidationContext.prototype;
9510
+ isNull = variableValues[variableName] == null;
9511
+ }
9516
9512
 
9517
- _proto2.getSchema = function getSchema() {
9518
- return this._schema;
9519
- };
9513
+ if (isNull && isNonNullType(argType)) {
9514
+ throw new GraphQLError("Argument \"".concat(name, "\" of non-null type \"").concat(inspect(argType), "\" ") + 'must not be null.', valueNode);
9515
+ }
9520
9516
 
9521
- return SDLValidationContext;
9522
- }(ASTValidationContext);
9517
+ var coercedValue = valueFromAST(valueNode, argType, variableValues);
9523
9518
 
9524
- /**
9525
- * @internal
9526
- */
9519
+ if (coercedValue === undefined) {
9520
+ // Note: ValuesOfCorrectTypeRule validation should catch this before
9521
+ // execution. This is a runtime check to ensure execution does not
9522
+ // continue with an invalid argument value.
9523
+ throw new GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat(print(valueNode), "."), valueNode);
9524
+ }
9527
9525
 
9528
- function validateSDL(documentAST, schemaToExtend) {
9529
- var rules = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : specifiedSDLRules;
9530
- var errors = [];
9531
- var context = new SDLValidationContext(documentAST, schemaToExtend, function (error) {
9532
- errors.push(error);
9533
- });
9534
- var visitors = rules.map(function (rule) {
9535
- return rule(context);
9536
- });
9537
- visit(documentAST, visitInParallel(visitors));
9538
- return errors;
9526
+ coercedValues[name] = coercedValue;
9527
+ }
9528
+
9529
+ return coercedValues;
9539
9530
  }
9540
9531
  /**
9541
- * Utility function which asserts a SDL document is valid by throwing an error
9542
- * if it is invalid.
9532
+ * Prepares an object map of argument values given a directive definition
9533
+ * and a AST node which may contain directives. Optionally also accepts a map
9534
+ * of variable values.
9543
9535
  *
9544
- * @internal
9536
+ * If the directive does not exist on the node, returns undefined.
9537
+ *
9538
+ * Note: The returned value is a plain Object with a prototype, since it is
9539
+ * exposed to user code. Care should be taken to not pull values from the
9540
+ * Object prototype.
9545
9541
  */
9546
9542
 
9547
- function assertValidSDL(documentAST) {
9548
- var errors = validateSDL(documentAST);
9543
+ function getDirectiveValues(directiveDef, node, variableValues) {
9544
+ var directiveNode = node.directives && find$1(node.directives, function (directive) {
9545
+ return directive.name.value === directiveDef.name;
9546
+ });
9549
9547
 
9550
- if (errors.length !== 0) {
9551
- throw new Error(errors.map(function (error) {
9552
- return error.message;
9553
- }).join('\n\n'));
9548
+ if (directiveNode) {
9549
+ return getArgumentValues(directiveDef, directiveNode, variableValues);
9554
9550
  }
9555
9551
  }
9556
9552
 
9553
+ function hasOwnProperty(obj, prop) {
9554
+ return Object.prototype.hasOwnProperty.call(obj, prop);
9555
+ }
9556
+
9557
9557
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
9558
9558
 
9559
9559
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -10269,6 +10269,116 @@ function buildASTSchema(documentAST, options) {
10269
10269
  return new GraphQLSchema(config);
10270
10270
  }
10271
10271
 
10272
+ /**
10273
+ * Strips characters that are not significant to the validity or execution
10274
+ * of a GraphQL document:
10275
+ * - UnicodeBOM
10276
+ * - WhiteSpace
10277
+ * - LineTerminator
10278
+ * - Comment
10279
+ * - Comma
10280
+ * - BlockString indentation
10281
+ *
10282
+ * Note: It is required to have a delimiter character between neighboring
10283
+ * non-punctuator tokens and this function always uses single space as delimiter.
10284
+ *
10285
+ * It is guaranteed that both input and output documents if parsed would result
10286
+ * in the exact same AST except for nodes location.
10287
+ *
10288
+ * Warning: It is guaranteed that this function will always produce stable results.
10289
+ * However, it's not guaranteed that it will stay the same between different
10290
+ * releases due to bugfixes or changes in the GraphQL specification.
10291
+ *
10292
+ * Query example:
10293
+ *
10294
+ * query SomeQuery($foo: String!, $bar: String) {
10295
+ * someField(foo: $foo, bar: $bar) {
10296
+ * a
10297
+ * b {
10298
+ * c
10299
+ * d
10300
+ * }
10301
+ * }
10302
+ * }
10303
+ *
10304
+ * Becomes:
10305
+ *
10306
+ * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}
10307
+ *
10308
+ * SDL example:
10309
+ *
10310
+ * """
10311
+ * Type description
10312
+ * """
10313
+ * type Foo {
10314
+ * """
10315
+ * Field description
10316
+ * """
10317
+ * bar: String
10318
+ * }
10319
+ *
10320
+ * Becomes:
10321
+ *
10322
+ * """Type description""" type Foo{"""Field description""" bar:String}
10323
+ */
10324
+
10325
+ function stripIgnoredCharacters(source) {
10326
+ var sourceObj = isSource(source) ? source : new Source(source);
10327
+ var body = sourceObj.body;
10328
+ var lexer = new Lexer(sourceObj);
10329
+ var strippedBody = '';
10330
+ var wasLastAddedTokenNonPunctuator = false;
10331
+
10332
+ while (lexer.advance().kind !== TokenKind.EOF) {
10333
+ var currentToken = lexer.token;
10334
+ var tokenKind = currentToken.kind;
10335
+ /**
10336
+ * Every two non-punctuator tokens should have space between them.
10337
+ * Also prevent case of non-punctuator token following by spread resulting
10338
+ * in invalid token (e.g. `1...` is invalid Float token).
10339
+ */
10340
+
10341
+ var isNonPunctuator = !isPunctuatorTokenKind(currentToken.kind);
10342
+
10343
+ if (wasLastAddedTokenNonPunctuator) {
10344
+ if (isNonPunctuator || currentToken.kind === TokenKind.SPREAD) {
10345
+ strippedBody += ' ';
10346
+ }
10347
+ }
10348
+
10349
+ var tokenBody = body.slice(currentToken.start, currentToken.end);
10350
+
10351
+ if (tokenKind === TokenKind.BLOCK_STRING) {
10352
+ strippedBody += dedentBlockString(tokenBody);
10353
+ } else {
10354
+ strippedBody += tokenBody;
10355
+ }
10356
+
10357
+ wasLastAddedTokenNonPunctuator = isNonPunctuator;
10358
+ }
10359
+
10360
+ return strippedBody;
10361
+ }
10362
+
10363
+ function dedentBlockString(blockStr) {
10364
+ // skip leading and trailing triple quotations
10365
+ var rawStr = blockStr.slice(3, -3);
10366
+ var body = dedentBlockStringValue(rawStr);
10367
+
10368
+ if (getBlockStringIndentation(body) > 0) {
10369
+ body = '\n' + body;
10370
+ }
10371
+
10372
+ var lastChar = body[body.length - 1];
10373
+ var hasTrailingQuote = lastChar === '"' && body.slice(-4) !== '\\"""';
10374
+
10375
+ if (hasTrailingQuote || lastChar === '\\') {
10376
+ body += '\n';
10377
+ }
10378
+
10379
+ return '"""' + body + '"""';
10380
+ }
10381
+
10272
10382
  /* Util Functions */
10273
10383
  function isOperationDefinitionNode(input) {
10274
10384
  return input.kind === 'OperationDefinition';
@@ -10690,30 +10800,20 @@ function transform(root) {
10690
10800
  };
10691
10801
  }
10692
10802
 
10693
- class LuvioGraphQLSchema {
10694
- constructor(luvioSchemaParams) {
10695
- this.schemaName = luvioSchemaParams.schemaName;
10696
- this.schema = luvioSchemaParams.schema;
10697
- }
10698
- }
10699
-
10700
10803
  /*
10701
10804
  Deprecated - Remove after existing usages are removed.
10702
10805
  */
10703
10806
  function parseAndVisit(source) {
10704
10807
  const ast = parse(source);
10705
10808
  return transform(ast);
10706
- }
10707
- function parseLuvioSchema(source, schemaName) {
10708
- const schema = buildASTSchema(parse(source));
10709
- return new LuvioGraphQLSchema({
10710
- schema,
10711
- schemaName,
10712
- });
10713
10809
  }
10714
10810
 
10811
+ exports.GraphQLScalarType = GraphQLScalarType;
10812
+ exports.GraphQLSchema = GraphQLSchema;
10715
10813
  exports.Kind = Kind;
10716
- exports.LuvioGraphQLSchema = LuvioGraphQLSchema;
10814
+ exports.buildASTSchema = buildASTSchema;
10717
10815
  exports.isScalarType = isScalarType;
10816
+ exports.parse = parse;
10718
10817
  exports.parseAndVisit = parseAndVisit;
10719
- exports.parseLuvioSchema = parseLuvioSchema;
10818
+ exports.print = print;
10819
+ exports.stripIgnoredCharacters = stripIgnoredCharacters;