graphql 15.4.0 → 15.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +10 -0
  2. package/error/GraphQLError.js +3 -3
  3. package/error/GraphQLError.js.flow +1 -1
  4. package/error/GraphQLError.mjs +1 -1
  5. package/execution/execute.js +8 -9
  6. package/execution/execute.js.flow +8 -10
  7. package/execution/execute.mjs +8 -8
  8. package/jsutils/instanceOf.js +15 -9
  9. package/jsutils/instanceOf.js.flow +12 -5
  10. package/jsutils/instanceOf.mjs +13 -5
  11. package/jsutils/isAsyncIterable.js +1 -7
  12. package/jsutils/isAsyncIterable.js.flow +1 -5
  13. package/jsutils/isAsyncIterable.mjs +1 -7
  14. package/jsutils/naturalCompare.js +69 -0
  15. package/jsutils/naturalCompare.js.flow +59 -0
  16. package/jsutils/naturalCompare.mjs +61 -0
  17. package/jsutils/safeArrayFrom.js +73 -0
  18. package/jsutils/safeArrayFrom.js.flow +59 -0
  19. package/jsutils/safeArrayFrom.mjs +66 -0
  20. package/jsutils/suggestionList.js +5 -1
  21. package/jsutils/suggestionList.js.flow +3 -1
  22. package/jsutils/suggestionList.mjs +3 -1
  23. package/language/blockString.js.flow +2 -2
  24. package/language/parser.d.ts +456 -1
  25. package/language/source.js.flow +1 -1
  26. package/package.json +2 -3
  27. package/type/definition.js +1 -0
  28. package/type/definition.js.flow +58 -45
  29. package/type/definition.mjs +1 -0
  30. package/type/directives.js.flow +9 -7
  31. package/type/schema.js.flow +1 -1
  32. package/utilities/TypeInfo.js.flow +1 -1
  33. package/utilities/astFromValue.js +6 -8
  34. package/utilities/astFromValue.js.flow +6 -6
  35. package/utilities/astFromValue.mjs +6 -7
  36. package/utilities/buildClientSchema.js +2 -1
  37. package/utilities/buildClientSchema.js.flow +1 -0
  38. package/utilities/buildClientSchema.mjs +2 -1
  39. package/utilities/coerceInputValue.js +7 -8
  40. package/utilities/coerceInputValue.js.flow +11 -8
  41. package/utilities/coerceInputValue.mjs +7 -7
  42. package/utilities/findBreakingChanges.js +6 -2
  43. package/utilities/findBreakingChanges.js.flow +6 -2
  44. package/utilities/findBreakingChanges.mjs +5 -2
  45. package/utilities/getIntrospectionQuery.d.ts +6 -0
  46. package/utilities/getIntrospectionQuery.js +8 -2
  47. package/utilities/getIntrospectionQuery.js.flow +16 -3
  48. package/utilities/getIntrospectionQuery.mjs +8 -2
  49. package/utilities/introspectionFromSchema.js +3 -1
  50. package/utilities/introspectionFromSchema.js.flow +2 -0
  51. package/utilities/introspectionFromSchema.mjs +3 -1
  52. package/utilities/lexicographicSortSchema.js +3 -1
  53. package/utilities/lexicographicSortSchema.js.flow +3 -2
  54. package/utilities/lexicographicSortSchema.mjs +2 -1
  55. package/utilities/separateOperations.js +44 -40
  56. package/utilities/separateOperations.js.flow +46 -36
  57. package/utilities/separateOperations.mjs +44 -40
  58. package/validation/ValidationContext.js.flow +3 -3
  59. package/validation/rules/FieldsOnCorrectTypeRule.js +3 -1
  60. package/validation/rules/FieldsOnCorrectTypeRule.js.flow +2 -1
  61. package/validation/rules/FieldsOnCorrectTypeRule.mjs +2 -1
  62. package/validation/rules/UniqueDirectiveNamesRule.js +1 -1
  63. package/validation/rules/UniqueDirectiveNamesRule.mjs +1 -1
  64. package/validation/rules/UniqueTypeNamesRule.js +1 -1
  65. package/validation/rules/UniqueTypeNamesRule.mjs +1 -1
  66. package/validation/validate.js.flow +4 -4
  67. package/version.js +3 -3
  68. package/version.js.flow +3 -3
  69. package/version.mjs +3 -3
  70. package/jsutils/isCollection.js +0 -47
  71. package/jsutils/isCollection.js.flow +0 -38
  72. package/jsutils/isCollection.mjs +0 -40
@@ -584,7 +584,7 @@ export class GraphQLScalarType {
584
584
  astNode: ?ScalarTypeDefinitionNode;
585
585
  extensionASTNodes: ?$ReadOnlyArray<ScalarTypeExtensionNode>;
586
586
 
587
- constructor(config: $ReadOnly<GraphQLScalarTypeConfig<mixed, mixed>>): void {
587
+ constructor(config: $ReadOnly<GraphQLScalarTypeConfig<mixed, mixed>>) {
588
588
  const parseValue = config.parseValue ?? identityFunc;
589
589
  this.name = config.name;
590
590
  this.description = config.description;
@@ -621,14 +621,7 @@ export class GraphQLScalarType {
621
621
  }
622
622
  }
623
623
 
624
- toConfig(): {|
625
- ...GraphQLScalarTypeConfig<mixed, mixed>,
626
- serialize: GraphQLScalarSerializer<mixed>,
627
- parseValue: GraphQLScalarValueParser<mixed>,
628
- parseLiteral: GraphQLScalarLiteralParser<mixed>,
629
- extensions: ?ReadOnlyObjMap<mixed>,
630
- extensionASTNodes: $ReadOnlyArray<ScalarTypeExtensionNode>,
631
- |} {
624
+ toConfig(): GraphQLScalarTypeNormalizedConfig {
632
625
  return {
633
626
  name: this.name,
634
627
  description: this.description,
@@ -687,6 +680,15 @@ export type GraphQLScalarTypeConfig<TInternal, TExternal> = {|
687
680
  extensionASTNodes?: ?$ReadOnlyArray<ScalarTypeExtensionNode>,
688
681
  |};
689
682
 
683
+ type GraphQLScalarTypeNormalizedConfig = {|
684
+ ...GraphQLScalarTypeConfig<mixed, mixed>,
685
+ serialize: GraphQLScalarSerializer<mixed>,
686
+ parseValue: GraphQLScalarValueParser<mixed>,
687
+ parseLiteral: GraphQLScalarLiteralParser<mixed>,
688
+ extensions: ?ReadOnlyObjMap<mixed>,
689
+ extensionASTNodes: $ReadOnlyArray<ScalarTypeExtensionNode>,
690
+ |};
691
+
690
692
  /**
691
693
  * Object Type Definition
692
694
  *
@@ -735,7 +737,7 @@ export class GraphQLObjectType {
735
737
  _fields: Thunk<GraphQLFieldMap<any, any>>;
736
738
  _interfaces: Thunk<Array<GraphQLInterfaceType>>;
737
739
 
738
- constructor(config: $ReadOnly<GraphQLObjectTypeConfig<any, any>>): void {
740
+ constructor(config: $ReadOnly<GraphQLObjectTypeConfig<any, any>>) {
739
741
  this.name = config.name;
740
742
  this.description = config.description;
741
743
  this.isTypeOf = config.isTypeOf;
@@ -767,13 +769,7 @@ export class GraphQLObjectType {
767
769
  return this._interfaces;
768
770
  }
769
771
 
770
- toConfig(): {|
771
- ...GraphQLObjectTypeConfig<any, any>,
772
- interfaces: Array<GraphQLInterfaceType>,
773
- fields: GraphQLFieldConfigMap<any, any>,
774
- extensions: ?ReadOnlyObjMap<mixed>,
775
- extensionASTNodes: $ReadOnlyArray<ObjectTypeExtensionNode>,
776
- |} {
772
+ toConfig(): GraphQLObjectTypeNormalizedConfig {
777
773
  return {
778
774
  name: this.name,
779
775
  description: this.description,
@@ -925,6 +921,14 @@ export type GraphQLObjectTypeConfig<TSource, TContext> = {|
925
921
  extensionASTNodes?: ?$ReadOnlyArray<ObjectTypeExtensionNode>,
926
922
  |};
927
923
 
924
+ type GraphQLObjectTypeNormalizedConfig = {|
925
+ ...GraphQLObjectTypeConfig<any, any>,
926
+ interfaces: Array<GraphQLInterfaceType>,
927
+ fields: GraphQLFieldConfigMap<any, any>,
928
+ extensions: ?ReadOnlyObjMap<mixed>,
929
+ extensionASTNodes: $ReadOnlyArray<ObjectTypeExtensionNode>,
930
+ |};
931
+
928
932
  /**
929
933
  * Note: returning GraphQLObjectType is deprecated and will be removed in v16.0.0
930
934
  */
@@ -1061,7 +1065,7 @@ export class GraphQLInterfaceType {
1061
1065
  _fields: Thunk<GraphQLFieldMap<any, any>>;
1062
1066
  _interfaces: Thunk<Array<GraphQLInterfaceType>>;
1063
1067
 
1064
- constructor(config: $ReadOnly<GraphQLInterfaceTypeConfig<any, any>>): void {
1068
+ constructor(config: $ReadOnly<GraphQLInterfaceTypeConfig<any, any>>) {
1065
1069
  this.name = config.name;
1066
1070
  this.description = config.description;
1067
1071
  this.resolveType = config.resolveType;
@@ -1093,13 +1097,7 @@ export class GraphQLInterfaceType {
1093
1097
  return this._interfaces;
1094
1098
  }
1095
1099
 
1096
- toConfig(): {|
1097
- ...GraphQLInterfaceTypeConfig<any, any>,
1098
- interfaces: Array<GraphQLInterfaceType>,
1099
- fields: GraphQLFieldConfigMap<any, any>,
1100
- extensions: ?ReadOnlyObjMap<mixed>,
1101
- extensionASTNodes: $ReadOnlyArray<InterfaceTypeExtensionNode>,
1102
- |} {
1100
+ toConfig(): GraphQLInterfaceTypeNormalizedConfig {
1103
1101
  return {
1104
1102
  name: this.name,
1105
1103
  description: this.description,
@@ -1145,6 +1143,14 @@ export type GraphQLInterfaceTypeConfig<TSource, TContext> = {|
1145
1143
  extensionASTNodes?: ?$ReadOnlyArray<InterfaceTypeExtensionNode>,
1146
1144
  |};
1147
1145
 
1146
+ export type GraphQLInterfaceTypeNormalizedConfig = {|
1147
+ ...GraphQLInterfaceTypeConfig<any, any>,
1148
+ interfaces: Array<GraphQLInterfaceType>,
1149
+ fields: GraphQLFieldConfigMap<any, any>,
1150
+ extensions: ?ReadOnlyObjMap<mixed>,
1151
+ extensionASTNodes: $ReadOnlyArray<InterfaceTypeExtensionNode>,
1152
+ |};
1153
+
1148
1154
  /**
1149
1155
  * Union Type Definition
1150
1156
  *
@@ -1178,7 +1184,7 @@ export class GraphQLUnionType {
1178
1184
 
1179
1185
  _types: Thunk<Array<GraphQLObjectType>>;
1180
1186
 
1181
- constructor(config: $ReadOnly<GraphQLUnionTypeConfig<any, any>>): void {
1187
+ constructor(config: $ReadOnly<GraphQLUnionTypeConfig<any, any>>) {
1182
1188
  this.name = config.name;
1183
1189
  this.description = config.description;
1184
1190
  this.resolveType = config.resolveType;
@@ -1202,12 +1208,7 @@ export class GraphQLUnionType {
1202
1208
  return this._types;
1203
1209
  }
1204
1210
 
1205
- toConfig(): {|
1206
- ...GraphQLUnionTypeConfig<any, any>,
1207
- types: Array<GraphQLObjectType>,
1208
- extensions: ?ReadOnlyObjMap<mixed>,
1209
- extensionASTNodes: $ReadOnlyArray<UnionTypeExtensionNode>,
1210
- |} {
1211
+ toConfig(): GraphQLUnionTypeNormalizedConfig {
1211
1212
  return {
1212
1213
  name: this.name,
1213
1214
  description: this.description,
@@ -1262,6 +1263,13 @@ export type GraphQLUnionTypeConfig<TSource, TContext> = {|
1262
1263
  extensionASTNodes?: ?$ReadOnlyArray<UnionTypeExtensionNode>,
1263
1264
  |};
1264
1265
 
1266
+ type GraphQLUnionTypeNormalizedConfig = {|
1267
+ ...GraphQLUnionTypeConfig<any, any>,
1268
+ types: Array<GraphQLObjectType>,
1269
+ extensions: ?ReadOnlyObjMap<mixed>,
1270
+ extensionASTNodes: $ReadOnlyArray<UnionTypeExtensionNode>,
1271
+ |};
1272
+
1265
1273
  /**
1266
1274
  * Enum Type Definition
1267
1275
  *
@@ -1294,7 +1302,7 @@ export class GraphQLEnumType /* <T> */ {
1294
1302
  _valueLookup: Map<any /* T */, GraphQLEnumValue>;
1295
1303
  _nameLookup: ObjMap<GraphQLEnumValue>;
1296
1304
 
1297
- constructor(config: $ReadOnly<GraphQLEnumTypeConfig /* <T> */>): void {
1305
+ constructor(config: $ReadOnly<GraphQLEnumTypeConfig /* <T> */>) {
1298
1306
  this.name = config.name;
1299
1307
  this.description = config.description;
1300
1308
  this.extensions = config.extensions && toObjMap(config.extensions);
@@ -1370,11 +1378,7 @@ export class GraphQLEnumType /* <T> */ {
1370
1378
  return enumValue.value;
1371
1379
  }
1372
1380
 
1373
- toConfig(): {|
1374
- ...GraphQLEnumTypeConfig,
1375
- extensions: ?ReadOnlyObjMap<mixed>,
1376
- extensionASTNodes: $ReadOnlyArray<EnumTypeExtensionNode>,
1377
- |} {
1381
+ toConfig(): GraphQLEnumTypeNormalizedConfig {
1378
1382
  const values = keyValMap(
1379
1383
  this.getValues(),
1380
1384
  (value) => value.name,
@@ -1463,6 +1467,12 @@ export type GraphQLEnumTypeConfig /* <T> */ = {|
1463
1467
  extensionASTNodes?: ?$ReadOnlyArray<EnumTypeExtensionNode>,
1464
1468
  |};
1465
1469
 
1470
+ type GraphQLEnumTypeNormalizedConfig = {|
1471
+ ...GraphQLEnumTypeConfig,
1472
+ extensions: ?ReadOnlyObjMap<mixed>,
1473
+ extensionASTNodes: $ReadOnlyArray<EnumTypeExtensionNode>,
1474
+ |};
1475
+
1466
1476
  export type GraphQLEnumValueConfigMap /* <T> */ = ObjMap<GraphQLEnumValueConfig /* <T> */>;
1467
1477
 
1468
1478
  export type GraphQLEnumValueConfig /* <T> */ = {|
@@ -1514,7 +1524,7 @@ export class GraphQLInputObjectType {
1514
1524
 
1515
1525
  _fields: Thunk<GraphQLInputFieldMap>;
1516
1526
 
1517
- constructor(config: $ReadOnly<GraphQLInputObjectTypeConfig>): void {
1527
+ constructor(config: $ReadOnly<GraphQLInputObjectTypeConfig>) {
1518
1528
  this.name = config.name;
1519
1529
  this.description = config.description;
1520
1530
  this.extensions = config.extensions && toObjMap(config.extensions);
@@ -1532,16 +1542,12 @@ export class GraphQLInputObjectType {
1532
1542
  return this._fields;
1533
1543
  }
1534
1544
 
1535
- toConfig(): {|
1536
- ...GraphQLInputObjectTypeConfig,
1537
- fields: GraphQLInputFieldConfigMap,
1538
- extensions: ?ReadOnlyObjMap<mixed>,
1539
- extensionASTNodes: $ReadOnlyArray<InputObjectTypeExtensionNode>,
1540
- |} {
1545
+ toConfig(): GraphQLInputObjectTypeNormalizedConfig {
1541
1546
  const fields = mapValue(this.getFields(), (field) => ({
1542
1547
  description: field.description,
1543
1548
  type: field.type,
1544
1549
  defaultValue: field.defaultValue,
1550
+ deprecationReason: field.deprecationReason,
1545
1551
  extensions: field.extensions,
1546
1552
  astNode: field.astNode,
1547
1553
  }));
@@ -1608,6 +1614,13 @@ export type GraphQLInputObjectTypeConfig = {|
1608
1614
  extensionASTNodes?: ?$ReadOnlyArray<InputObjectTypeExtensionNode>,
1609
1615
  |};
1610
1616
 
1617
+ type GraphQLInputObjectTypeNormalizedConfig = {|
1618
+ ...GraphQLInputObjectTypeConfig,
1619
+ fields: GraphQLInputFieldConfigMap,
1620
+ extensions: ?ReadOnlyObjMap<mixed>,
1621
+ extensionASTNodes: $ReadOnlyArray<InputObjectTypeExtensionNode>,
1622
+ |};
1623
+
1611
1624
  export type GraphQLInputFieldConfig = {|
1612
1625
  description?: ?string,
1613
1626
  type: GraphQLInputType,
@@ -1049,6 +1049,7 @@ export var GraphQLInputObjectType = /*#__PURE__*/function () {
1049
1049
  description: field.description,
1050
1050
  type: field.type,
1051
1051
  defaultValue: field.defaultValue,
1052
+ deprecationReason: field.deprecationReason,
1052
1053
  extensions: field.extensions,
1053
1054
  astNode: field.astNode
1054
1055
  };
@@ -54,7 +54,7 @@ export class GraphQLDirective {
54
54
  extensions: ?ReadOnlyObjMap<mixed>;
55
55
  astNode: ?DirectiveDefinitionNode;
56
56
 
57
- constructor(config: $ReadOnly<GraphQLDirectiveConfig>): void {
57
+ constructor(config: $ReadOnly<GraphQLDirectiveConfig>) {
58
58
  this.name = config.name;
59
59
  this.description = config.description;
60
60
  this.locations = config.locations;
@@ -85,12 +85,7 @@ export class GraphQLDirective {
85
85
  }));
86
86
  }
87
87
 
88
- toConfig(): {|
89
- ...GraphQLDirectiveConfig,
90
- args: GraphQLFieldConfigArgumentMap,
91
- isRepeatable: boolean,
92
- extensions: ?ReadOnlyObjMap<mixed>,
93
- |} {
88
+ toConfig(): GraphQLDirectiveNormalizedConfig {
94
89
  return {
95
90
  name: this.name,
96
91
  description: this.description,
@@ -129,6 +124,13 @@ export type GraphQLDirectiveConfig = {|
129
124
  astNode?: ?DirectiveDefinitionNode,
130
125
  |};
131
126
 
127
+ type GraphQLDirectiveNormalizedConfig = {|
128
+ ...GraphQLDirectiveConfig,
129
+ args: GraphQLFieldConfigArgumentMap,
130
+ isRepeatable: boolean,
131
+ extensions: ?ReadOnlyObjMap<mixed>,
132
+ |};
133
+
132
134
  /**
133
135
  * Used to conditionally include fields or fragments.
134
136
  */
@@ -143,7 +143,7 @@ export class GraphQLSchema {
143
143
  // Used as a cache for validateSchema().
144
144
  __validationErrors: ?$ReadOnlyArray<GraphQLError>;
145
145
 
146
- constructor(config: $ReadOnly<GraphQLSchemaConfig>): void {
146
+ constructor(config: $ReadOnly<GraphQLSchemaConfig>) {
147
147
  // If this schema was built from a source known to be valid, then it may be
148
148
  // marked with assumeValid to avoid an additional type system validation.
149
149
  this.__validationErrors = config.assumeValid === true ? [] : undefined;
@@ -65,7 +65,7 @@ export class TypeInfo {
65
65
  // Initial type may be provided in rare cases to facilitate traversals
66
66
  // beginning somewhere other than documents.
67
67
  initialType?: GraphQLType,
68
- ): void {
68
+ ) {
69
69
  this._schema = schema;
70
70
  this._typeStack = [];
71
71
  this._parentTypeStack = [];
@@ -7,8 +7,6 @@ exports.astFromValue = astFromValue;
7
7
 
8
8
  var _isFinite = _interopRequireDefault(require("../polyfills/isFinite.js"));
9
9
 
10
- var _arrayFrom3 = _interopRequireDefault(require("../polyfills/arrayFrom.js"));
11
-
12
10
  var _objectValues3 = _interopRequireDefault(require("../polyfills/objectValues.js"));
13
11
 
14
12
  var _inspect = _interopRequireDefault(require("../jsutils/inspect.js"));
@@ -17,7 +15,7 @@ var _invariant = _interopRequireDefault(require("../jsutils/invariant.js"));
17
15
 
18
16
  var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike.js"));
19
17
 
20
- var _isCollection = _interopRequireDefault(require("../jsutils/isCollection.js"));
18
+ var _safeArrayFrom = _interopRequireDefault(require("../jsutils/safeArrayFrom.js"));
21
19
 
22
20
  var _kinds = require("../language/kinds.js");
23
21
 
@@ -75,13 +73,13 @@ function astFromValue(value, type) {
75
73
 
76
74
  if ((0, _definition.isListType)(type)) {
77
75
  var itemType = type.ofType;
76
+ var items = (0, _safeArrayFrom.default)(value);
78
77
 
79
- if ((0, _isCollection.default)(value)) {
80
- var valuesNodes = []; // Since we transpile for-of in loose mode it doesn't support iterators
81
- // and it's required to first convert iteratable into array
78
+ if (items != null) {
79
+ var valuesNodes = [];
82
80
 
83
- for (var _i2 = 0, _arrayFrom2 = (0, _arrayFrom3.default)(value); _i2 < _arrayFrom2.length; _i2++) {
84
- var item = _arrayFrom2[_i2];
81
+ for (var _i2 = 0; _i2 < items.length; _i2++) {
82
+ var item = items[_i2];
85
83
  var itemNode = astFromValue(item, itemType);
86
84
 
87
85
  if (itemNode != null) {
@@ -1,12 +1,11 @@
1
1
  // @flow strict
2
2
  import isFinite from '../polyfills/isFinite';
3
- import arrayFrom from '../polyfills/arrayFrom';
4
3
  import objectValues from '../polyfills/objectValues';
5
4
 
6
5
  import inspect from '../jsutils/inspect';
7
6
  import invariant from '../jsutils/invariant';
8
7
  import isObjectLike from '../jsutils/isObjectLike';
9
- import isCollection from '../jsutils/isCollection';
8
+ import safeArrayFrom from '../jsutils/safeArrayFrom';
10
9
 
11
10
  import type { ValueNode } from '../language/ast';
12
11
  import { Kind } from '../language/kinds';
@@ -65,11 +64,11 @@ export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode {
65
64
  // the value is not an array, convert the value using the list's item type.
66
65
  if (isListType(type)) {
67
66
  const itemType = type.ofType;
68
- if (isCollection(value)) {
67
+
68
+ const items = safeArrayFrom(value);
69
+ if (items != null) {
69
70
  const valuesNodes = [];
70
- // Since we transpile for-of in loose mode it doesn't support iterators
71
- // and it's required to first convert iteratable into array
72
- for (const item of arrayFrom(value)) {
71
+ for (const item of items) {
73
72
  const itemNode = astFromValue(item, itemType);
74
73
  if (itemNode != null) {
75
74
  valuesNodes.push(itemNode);
@@ -77,6 +76,7 @@ export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode {
77
76
  }
78
77
  return { kind: Kind.LIST, values: valuesNodes };
79
78
  }
79
+
80
80
  return astFromValue(value, itemType);
81
81
  }
82
82
 
@@ -1,10 +1,9 @@
1
1
  import isFinite from "../polyfills/isFinite.mjs";
2
- import arrayFrom from "../polyfills/arrayFrom.mjs";
3
2
  import objectValues from "../polyfills/objectValues.mjs";
4
3
  import inspect from "../jsutils/inspect.mjs";
5
4
  import invariant from "../jsutils/invariant.mjs";
6
5
  import isObjectLike from "../jsutils/isObjectLike.mjs";
7
- import isCollection from "../jsutils/isCollection.mjs";
6
+ import safeArrayFrom from "../jsutils/safeArrayFrom.mjs";
8
7
  import { Kind } from "../language/kinds.mjs";
9
8
  import { GraphQLID } from "../type/scalars.mjs";
10
9
  import { isLeafType, isEnumType, isInputObjectType, isListType, isNonNullType } from "../type/definition.mjs";
@@ -57,13 +56,13 @@ export function astFromValue(value, type) {
57
56
 
58
57
  if (isListType(type)) {
59
58
  var itemType = type.ofType;
59
+ var items = safeArrayFrom(value);
60
60
 
61
- if (isCollection(value)) {
62
- var valuesNodes = []; // Since we transpile for-of in loose mode it doesn't support iterators
63
- // and it's required to first convert iteratable into array
61
+ if (items != null) {
62
+ var valuesNodes = [];
64
63
 
65
- for (var _i2 = 0, _arrayFrom2 = arrayFrom(value); _i2 < _arrayFrom2.length; _i2++) {
66
- var item = _arrayFrom2[_i2];
64
+ for (var _i2 = 0; _i2 < items.length; _i2++) {
65
+ var item = items[_i2];
67
66
  var itemNode = astFromValue(item, itemType);
68
67
 
69
68
  if (itemNode != null) {
@@ -307,7 +307,8 @@ function buildClientSchema(introspection, options) {
307
307
  return {
308
308
  description: inputValueIntrospection.description,
309
309
  type: type,
310
- defaultValue: defaultValue
310
+ defaultValue: defaultValue,
311
+ deprecationReason: inputValueIntrospection.deprecationReason
311
312
  };
312
313
  }
313
314
 
@@ -378,6 +378,7 @@ export function buildClientSchema(
378
378
  description: inputValueIntrospection.description,
379
379
  type,
380
380
  defaultValue,
381
+ deprecationReason: inputValueIntrospection.deprecationReason,
381
382
  };
382
383
  }
383
384
 
@@ -287,7 +287,8 @@ export function buildClientSchema(introspection, options) {
287
287
  return {
288
288
  description: inputValueIntrospection.description,
289
289
  type: type,
290
- defaultValue: defaultValue
290
+ defaultValue: defaultValue,
291
+ deprecationReason: inputValueIntrospection.deprecationReason
291
292
  };
292
293
  }
293
294
 
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.coerceInputValue = coerceInputValue;
7
7
 
8
- var _arrayFrom = _interopRequireDefault(require("../polyfills/arrayFrom.js"));
9
-
10
8
  var _objectValues3 = _interopRequireDefault(require("../polyfills/objectValues.js"));
11
9
 
12
10
  var _inspect = _interopRequireDefault(require("../jsutils/inspect.js"));
@@ -17,7 +15,7 @@ var _didYouMean = _interopRequireDefault(require("../jsutils/didYouMean.js"));
17
15
 
18
16
  var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike.js"));
19
17
 
20
- var _isCollection = _interopRequireDefault(require("../jsutils/isCollection.js"));
18
+ var _safeArrayFrom = _interopRequireDefault(require("../jsutils/safeArrayFrom.js"));
21
19
 
22
20
  var _suggestionList = _interopRequireDefault(require("../jsutils/suggestionList.js"));
23
21
 
@@ -67,12 +65,13 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
67
65
 
68
66
  if ((0, _definition.isListType)(type)) {
69
67
  var itemType = type.ofType;
68
+ var coercedList = (0, _safeArrayFrom.default)(inputValue, function (itemValue, index) {
69
+ var itemPath = (0, _Path.addPath)(path, index, undefined);
70
+ return coerceInputValueImpl(itemValue, itemType, onError, itemPath);
71
+ });
70
72
 
71
- if ((0, _isCollection.default)(inputValue)) {
72
- return (0, _arrayFrom.default)(inputValue, function (itemValue, index) {
73
- var itemPath = (0, _Path.addPath)(path, index, undefined);
74
- return coerceInputValueImpl(itemValue, itemType, onError, itemPath);
75
- });
73
+ if (coercedList != null) {
74
+ return coercedList;
76
75
  } // Lists accept a non-list value as a list of one.
77
76
 
78
77
 
@@ -1,5 +1,4 @@
1
1
  // @flow strict
2
- import arrayFrom from '../polyfills/arrayFrom';
3
2
  import objectValues from '../polyfills/objectValues';
4
3
 
5
4
  import type { Path } from '../jsutils/Path';
@@ -7,7 +6,7 @@ import inspect from '../jsutils/inspect';
7
6
  import invariant from '../jsutils/invariant';
8
7
  import didYouMean from '../jsutils/didYouMean';
9
8
  import isObjectLike from '../jsutils/isObjectLike';
10
- import isCollection from '../jsutils/isCollection';
9
+ import safeArrayFrom from '../jsutils/safeArrayFrom';
11
10
  import suggestionList from '../jsutils/suggestionList';
12
11
  import printPathArray from '../jsutils/printPathArray';
13
12
  import { addPath, pathToArray } from '../jsutils/Path';
@@ -34,7 +33,7 @@ type OnErrorCB = (
34
33
  export function coerceInputValue(
35
34
  inputValue: mixed,
36
35
  type: GraphQLInputType,
37
- onError?: OnErrorCB = defaultOnError,
36
+ onError: OnErrorCB = defaultOnError,
38
37
  ): mixed {
39
38
  return coerceInputValueImpl(inputValue, type, onError);
40
39
  }
@@ -79,12 +78,16 @@ function coerceInputValueImpl(
79
78
 
80
79
  if (isListType(type)) {
81
80
  const itemType = type.ofType;
82
- if (isCollection(inputValue)) {
83
- return arrayFrom(inputValue, (itemValue, index) => {
84
- const itemPath = addPath(path, index, undefined);
85
- return coerceInputValueImpl(itemValue, itemType, onError, itemPath);
86
- });
81
+
82
+ const coercedList = safeArrayFrom(inputValue, (itemValue, index) => {
83
+ const itemPath = addPath(path, index, undefined);
84
+ return coerceInputValueImpl(itemValue, itemType, onError, itemPath);
85
+ });
86
+
87
+ if (coercedList != null) {
88
+ return coercedList;
87
89
  }
90
+
88
91
  // Lists accept a non-list value as a list of one.
89
92
  return [coerceInputValueImpl(inputValue, itemType, onError, path)];
90
93
  }
@@ -1,10 +1,9 @@
1
- import arrayFrom from "../polyfills/arrayFrom.mjs";
2
1
  import objectValues from "../polyfills/objectValues.mjs";
3
2
  import inspect from "../jsutils/inspect.mjs";
4
3
  import invariant from "../jsutils/invariant.mjs";
5
4
  import didYouMean from "../jsutils/didYouMean.mjs";
6
5
  import isObjectLike from "../jsutils/isObjectLike.mjs";
7
- import isCollection from "../jsutils/isCollection.mjs";
6
+ import safeArrayFrom from "../jsutils/safeArrayFrom.mjs";
8
7
  import suggestionList from "../jsutils/suggestionList.mjs";
9
8
  import printPathArray from "../jsutils/printPathArray.mjs";
10
9
  import { addPath, pathToArray } from "../jsutils/Path.mjs";
@@ -47,12 +46,13 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
47
46
 
48
47
  if (isListType(type)) {
49
48
  var itemType = type.ofType;
49
+ var coercedList = safeArrayFrom(inputValue, function (itemValue, index) {
50
+ var itemPath = addPath(path, index, undefined);
51
+ return coerceInputValueImpl(itemValue, itemType, onError, itemPath);
52
+ });
50
53
 
51
- if (isCollection(inputValue)) {
52
- return arrayFrom(inputValue, function (itemValue, index) {
53
- var itemPath = addPath(path, index, undefined);
54
- return coerceInputValueImpl(itemValue, itemType, onError, itemPath);
55
- });
54
+ if (coercedList != null) {
55
+ return coercedList;
56
56
  } // Lists accept a non-list value as a list of one.
57
57
 
58
58
 
@@ -15,6 +15,8 @@ var _inspect = _interopRequireDefault(require("../jsutils/inspect.js"));
15
15
 
16
16
  var _invariant = _interopRequireDefault(require("../jsutils/invariant.js"));
17
17
 
18
+ var _naturalCompare = _interopRequireDefault(require("../jsutils/naturalCompare.js"));
19
+
18
20
  var _printer = require("../language/printer.js");
19
21
 
20
22
  var _visitor = require("../language/visitor.js");
@@ -467,8 +469,10 @@ function stringifyValue(value, type) {
467
469
  ast != null || (0, _invariant.default)(0);
468
470
  var sortedAST = (0, _visitor.visit)(ast, {
469
471
  ObjectValue: function ObjectValue(objectNode) {
470
- var fields = [].concat(objectNode.fields).sort(function (fieldA, fieldB) {
471
- return fieldA.name.value.localeCompare(fieldB.name.value);
472
+ // Make a copy since sort mutates array
473
+ var fields = [].concat(objectNode.fields);
474
+ fields.sort(function (fieldA, fieldB) {
475
+ return (0, _naturalCompare.default)(fieldA.name.value, fieldB.name.value);
472
476
  });
473
477
  return _objectSpread(_objectSpread({}, objectNode), {}, {
474
478
  fields: fields
@@ -4,6 +4,7 @@ import objectValues from '../polyfills/objectValues';
4
4
  import keyMap from '../jsutils/keyMap';
5
5
  import inspect from '../jsutils/inspect';
6
6
  import invariant from '../jsutils/invariant';
7
+ import naturalCompare from '../jsutils/naturalCompare';
7
8
 
8
9
  import { print } from '../language/printer';
9
10
  import { visit } from '../language/visitor';
@@ -542,8 +543,11 @@ function stringifyValue(value: mixed, type: GraphQLInputType): string {
542
543
 
543
544
  const sortedAST = visit(ast, {
544
545
  ObjectValue(objectNode) {
545
- const fields = [...objectNode.fields].sort((fieldA, fieldB) =>
546
- fieldA.name.value.localeCompare(fieldB.name.value),
546
+ // Make a copy since sort mutates array
547
+ const fields = [...objectNode.fields];
548
+
549
+ fields.sort((fieldA, fieldB) =>
550
+ naturalCompare(fieldA.name.value, fieldB.name.value),
547
551
  );
548
552
  return { ...objectNode, fields };
549
553
  },
@@ -8,6 +8,7 @@ import objectValues from "../polyfills/objectValues.mjs";
8
8
  import keyMap from "../jsutils/keyMap.mjs";
9
9
  import inspect from "../jsutils/inspect.mjs";
10
10
  import invariant from "../jsutils/invariant.mjs";
11
+ import naturalCompare from "../jsutils/naturalCompare.mjs";
11
12
  import { print } from "../language/printer.mjs";
12
13
  import { visit } from "../language/visitor.mjs";
13
14
  import { isSpecifiedScalarType } from "../type/scalars.mjs";
@@ -444,8 +445,10 @@ function stringifyValue(value, type) {
444
445
  ast != null || invariant(0);
445
446
  var sortedAST = visit(ast, {
446
447
  ObjectValue: function ObjectValue(objectNode) {
447
- var fields = [].concat(objectNode.fields).sort(function (fieldA, fieldB) {
448
- return fieldA.name.value.localeCompare(fieldB.name.value);
448
+ // Make a copy since sort mutates array
449
+ var fields = [].concat(objectNode.fields);
450
+ fields.sort(function (fieldA, fieldB) {
451
+ return naturalCompare(fieldA.name.value, fieldB.name.value);
449
452
  });
450
453
  return _objectSpread(_objectSpread({}, objectNode), {}, {
451
454
  fields: fields
@@ -18,6 +18,10 @@ export interface IntrospectionOptions {
18
18
  // Whether to include `description` field on schema.
19
19
  // Default: false
20
20
  schemaDescription?: boolean;
21
+
22
+ // Whether target GraphQL server support deprecation of input values.
23
+ // Default: false
24
+ inputValueDeprecation?: boolean;
21
25
  }
22
26
 
23
27
  export function getIntrospectionQuery(options?: IntrospectionOptions): string;
@@ -169,6 +173,8 @@ export interface IntrospectionInputValue {
169
173
  readonly description?: Maybe<string>;
170
174
  readonly type: IntrospectionInputTypeRef;
171
175
  readonly defaultValue?: Maybe<string>;
176
+ readonly isDeprecated?: boolean;
177
+ readonly deprecationReason?: Maybe<string>;
172
178
  }
173
179
 
174
180
  export interface IntrospectionEnumValue {
@@ -16,12 +16,18 @@ function getIntrospectionQuery(options) {
16
16
  descriptions: true,
17
17
  specifiedByUrl: false,
18
18
  directiveIsRepeatable: false,
19
- schemaDescription: false
19
+ schemaDescription: false,
20
+ inputValueDeprecation: false
20
21
  }, options);
21
22
 
22
23
  var descriptions = optionsWithDefault.descriptions ? 'description' : '';
23
24
  var specifiedByUrl = optionsWithDefault.specifiedByUrl ? 'specifiedByUrl' : '';
24
25
  var directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable ? 'isRepeatable' : '';
25
26
  var schemaDescription = optionsWithDefault.schemaDescription ? descriptions : '';
26
- return "\n query IntrospectionQuery {\n __schema {\n ".concat(schemaDescription, "\n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n ...FullType\n }\n directives {\n name\n ").concat(descriptions, "\n ").concat(directiveIsRepeatable, "\n locations\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n ").concat(descriptions, "\n ").concat(specifiedByUrl, "\n fields(includeDeprecated: true) {\n name\n ").concat(descriptions, "\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n ").concat(descriptions, "\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n ").concat(descriptions, "\n type { ...TypeRef }\n defaultValue\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n ");
27
+
28
+ function inputDeprecation(str) {
29
+ return optionsWithDefault.inputValueDeprecation ? str : '';
30
+ }
31
+
32
+ return "\n query IntrospectionQuery {\n __schema {\n ".concat(schemaDescription, "\n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n ...FullType\n }\n directives {\n name\n ").concat(descriptions, "\n ").concat(directiveIsRepeatable, "\n locations\n args").concat(inputDeprecation('(includeDeprecated: true)'), " {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n ").concat(descriptions, "\n ").concat(specifiedByUrl, "\n fields(includeDeprecated: true) {\n name\n ").concat(descriptions, "\n args").concat(inputDeprecation('(includeDeprecated: true)'), " {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields").concat(inputDeprecation('(includeDeprecated: true)'), " {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n ").concat(descriptions, "\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n ").concat(descriptions, "\n type { ...TypeRef }\n defaultValue\n ").concat(inputDeprecation('isDeprecated'), "\n ").concat(inputDeprecation('deprecationReason'), "\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n ");
27
33
  }