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