graphql 16.14.2 → 16.15.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.
Files changed (240) hide show
  1. package/error/GraphQLError.d.ts +5 -1
  2. package/error/GraphQLError.js +12 -7
  3. package/error/GraphQLError.mjs +13 -6
  4. package/error/locatedError.d.ts +6 -4
  5. package/error/locatedError.js +6 -4
  6. package/error/locatedError.mjs +6 -4
  7. package/execution/collectFields.d.ts +1 -0
  8. package/execution/collectFields.js +9 -0
  9. package/execution/collectFields.mjs +9 -0
  10. package/execution/execute.d.ts +9 -10
  11. package/execution/execute.js +44 -29
  12. package/execution/execute.mjs +44 -29
  13. package/execution/mapAsyncIterator.js +12 -11
  14. package/execution/mapAsyncIterator.mjs +12 -11
  15. package/execution/subscribe.d.ts +5 -2
  16. package/execution/subscribe.js +5 -2
  17. package/execution/subscribe.mjs +5 -2
  18. package/execution/values.d.ts +43 -21
  19. package/execution/values.js +52 -24
  20. package/execution/values.mjs +51 -23
  21. package/graphql.d.ts +8 -14
  22. package/graphql.js +16 -15
  23. package/graphql.mjs +11 -15
  24. package/jsutils/SetMap.d.ts +14 -0
  25. package/jsutils/SetMap.js +48 -0
  26. package/jsutils/SetMap.mjs +39 -0
  27. package/jsutils/isIterableObject.d.ts +2 -0
  28. package/jsutils/isIterableObject.js +2 -0
  29. package/jsutils/isIterableObject.mjs +2 -0
  30. package/jsutils/keyMap.d.ts +2 -0
  31. package/jsutils/keyMap.js +2 -0
  32. package/jsutils/keyMap.mjs +2 -0
  33. package/jsutils/keyValMap.d.ts +3 -3
  34. package/jsutils/keyValMap.js +3 -3
  35. package/jsutils/keyValMap.mjs +3 -3
  36. package/language/ast.d.ts +2 -6
  37. package/language/ast.js +2 -6
  38. package/language/ast.mjs +2 -6
  39. package/language/lexer.d.ts +6 -0
  40. package/language/lexer.js +22 -0
  41. package/language/lexer.mjs +22 -0
  42. package/language/location.d.ts +8 -3
  43. package/language/location.js +57 -17
  44. package/language/location.mjs +56 -16
  45. package/language/parser.d.ts +27 -13
  46. package/language/parser.js +31 -9
  47. package/language/parser.mjs +31 -9
  48. package/language/predicates.d.ts +10 -3
  49. package/language/predicates.js +10 -3
  50. package/language/predicates.mjs +10 -3
  51. package/language/printLocation.d.ts +2 -6
  52. package/language/printLocation.js +2 -6
  53. package/language/printLocation.mjs +2 -6
  54. package/language/printer.d.ts +22 -3
  55. package/language/printer.js +394 -308
  56. package/language/printer.mjs +394 -308
  57. package/language/reducer.d.ts +32 -0
  58. package/language/reducer.js +95 -0
  59. package/language/reducer.mjs +86 -0
  60. package/language/source.d.ts +4 -5
  61. package/language/source.js +4 -5
  62. package/language/source.mjs +4 -5
  63. package/language/visitor.d.ts +16 -10
  64. package/language/visitor.js +15 -7
  65. package/language/visitor.mjs +15 -7
  66. package/package.json +1 -4
  67. package/type/definition.d.ts +170 -102
  68. package/type/definition.js +169 -96
  69. package/type/definition.mjs +168 -95
  70. package/type/directives.d.ts +12 -6
  71. package/type/directives.js +12 -6
  72. package/type/directives.mjs +12 -6
  73. package/type/scalars.js +8 -11
  74. package/type/scalars.mjs +1 -1
  75. package/type/schema.d.ts +36 -11
  76. package/type/schema.js +35 -10
  77. package/type/schema.mjs +35 -10
  78. package/type/validate.d.ts +1 -3
  79. package/type/validate.js +1 -3
  80. package/type/validate.mjs +1 -3
  81. package/utilities/TypeInfo.d.ts +15 -11
  82. package/utilities/TypeInfo.js +15 -11
  83. package/utilities/TypeInfo.mjs +15 -11
  84. package/utilities/assertValidName.d.ts +1 -1
  85. package/utilities/assertValidName.js +1 -1
  86. package/utilities/assertValidName.mjs +1 -1
  87. package/utilities/astFromValue.d.ts +3 -1
  88. package/utilities/astFromValue.js +3 -1
  89. package/utilities/astFromValue.mjs +3 -1
  90. package/utilities/buildASTSchema.d.ts +8 -8
  91. package/utilities/buildASTSchema.js +9 -20
  92. package/utilities/buildASTSchema.mjs +9 -20
  93. package/utilities/buildClientSchema.d.ts +6 -2
  94. package/utilities/buildClientSchema.js +6 -2
  95. package/utilities/buildClientSchema.mjs +6 -2
  96. package/utilities/coerceInputValue.d.ts +9 -3
  97. package/utilities/coerceInputValue.js +60 -13
  98. package/utilities/coerceInputValue.mjs +58 -13
  99. package/utilities/concatAST.d.ts +4 -1
  100. package/utilities/concatAST.js +4 -1
  101. package/utilities/concatAST.mjs +4 -1
  102. package/utilities/extendSchema.d.ts +7 -4
  103. package/utilities/extendSchema.js +7 -4
  104. package/utilities/extendSchema.mjs +7 -4
  105. package/utilities/findBreakingChanges.d.ts +2 -2
  106. package/utilities/findBreakingChanges.js +2 -2
  107. package/utilities/findBreakingChanges.mjs +2 -2
  108. package/utilities/getIntrospectionQuery.d.ts +9 -9
  109. package/utilities/getIntrospectionQuery.js +8 -8
  110. package/utilities/getIntrospectionQuery.mjs +8 -8
  111. package/utilities/getOperationAST.d.ts +2 -2
  112. package/utilities/getOperationAST.js +2 -2
  113. package/utilities/getOperationAST.mjs +2 -2
  114. package/utilities/getOperationRootType.d.ts +3 -1
  115. package/utilities/getOperationRootType.js +3 -1
  116. package/utilities/getOperationRootType.mjs +3 -1
  117. package/utilities/introspectionFromSchema.d.ts +12 -4
  118. package/utilities/introspectionFromSchema.js +12 -4
  119. package/utilities/introspectionFromSchema.mjs +12 -4
  120. package/utilities/lexicographicSortSchema.d.ts +17 -13
  121. package/utilities/lexicographicSortSchema.js +17 -13
  122. package/utilities/lexicographicSortSchema.mjs +17 -13
  123. package/utilities/printSchema.d.ts +7 -4
  124. package/utilities/printSchema.js +7 -4
  125. package/utilities/printSchema.mjs +7 -4
  126. package/utilities/resolveSchemaCoordinate.d.ts +9 -8
  127. package/utilities/resolveSchemaCoordinate.js +9 -8
  128. package/utilities/resolveSchemaCoordinate.mjs +9 -8
  129. package/utilities/separateOperations.d.ts +2 -2
  130. package/utilities/separateOperations.js +2 -2
  131. package/utilities/separateOperations.mjs +2 -2
  132. package/utilities/stripIgnoredCharacters.d.ts +19 -5
  133. package/utilities/stripIgnoredCharacters.js +19 -5
  134. package/utilities/stripIgnoredCharacters.mjs +19 -5
  135. package/utilities/typeComparators.d.ts +1 -5
  136. package/utilities/typeComparators.js +1 -5
  137. package/utilities/typeComparators.mjs +1 -5
  138. package/utilities/valueFromAST.js +4 -4
  139. package/utilities/valueFromAST.mjs +4 -4
  140. package/utilities/valueFromASTUntyped.d.ts +1 -3
  141. package/utilities/valueFromASTUntyped.js +1 -3
  142. package/utilities/valueFromASTUntyped.mjs +1 -3
  143. package/validation/ValidationContext.d.ts +22 -3
  144. package/validation/ValidationContext.js +84 -27
  145. package/validation/ValidationContext.mjs +82 -27
  146. package/validation/rules/ExecutableDefinitionsRule.d.ts +6 -4
  147. package/validation/rules/ExecutableDefinitionsRule.js +6 -4
  148. package/validation/rules/ExecutableDefinitionsRule.mjs +6 -4
  149. package/validation/rules/FieldsOnCorrectTypeRule.d.ts +4 -4
  150. package/validation/rules/FieldsOnCorrectTypeRule.js +10 -6
  151. package/validation/rules/FieldsOnCorrectTypeRule.mjs +12 -6
  152. package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -4
  153. package/validation/rules/FragmentsOnCompositeTypesRule.js +6 -4
  154. package/validation/rules/FragmentsOnCompositeTypesRule.mjs +6 -4
  155. package/validation/rules/KnownArgumentNamesRule.d.ts +4 -4
  156. package/validation/rules/KnownArgumentNamesRule.js +26 -17
  157. package/validation/rules/KnownArgumentNamesRule.mjs +21 -11
  158. package/validation/rules/KnownDirectivesRule.d.ts +1 -3
  159. package/validation/rules/KnownDirectivesRule.js +1 -3
  160. package/validation/rules/KnownDirectivesRule.mjs +1 -3
  161. package/validation/rules/KnownFragmentNamesRule.d.ts +4 -4
  162. package/validation/rules/KnownFragmentNamesRule.js +4 -4
  163. package/validation/rules/KnownFragmentNamesRule.mjs +4 -4
  164. package/validation/rules/KnownTypeNamesRule.d.ts +1 -3
  165. package/validation/rules/KnownTypeNamesRule.js +7 -7
  166. package/validation/rules/KnownTypeNamesRule.mjs +7 -7
  167. package/validation/rules/LoneAnonymousOperationRule.d.ts +6 -4
  168. package/validation/rules/LoneAnonymousOperationRule.js +6 -4
  169. package/validation/rules/LoneAnonymousOperationRule.mjs +6 -4
  170. package/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -4
  171. package/validation/rules/MaxIntrospectionDepthRule.js +44 -19
  172. package/validation/rules/MaxIntrospectionDepthRule.mjs +44 -19
  173. package/validation/rules/NoFragmentCyclesRule.d.ts +1 -3
  174. package/validation/rules/NoFragmentCyclesRule.js +1 -3
  175. package/validation/rules/NoFragmentCyclesRule.mjs +1 -3
  176. package/validation/rules/NoUndefinedVariablesRule.d.ts +4 -4
  177. package/validation/rules/NoUndefinedVariablesRule.js +4 -4
  178. package/validation/rules/NoUndefinedVariablesRule.mjs +4 -4
  179. package/validation/rules/NoUnusedFragmentsRule.d.ts +4 -4
  180. package/validation/rules/NoUnusedFragmentsRule.js +10 -14
  181. package/validation/rules/NoUnusedFragmentsRule.mjs +10 -14
  182. package/validation/rules/NoUnusedVariablesRule.d.ts +4 -4
  183. package/validation/rules/NoUnusedVariablesRule.js +4 -4
  184. package/validation/rules/NoUnusedVariablesRule.mjs +4 -4
  185. package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +8 -6
  186. package/validation/rules/OverlappingFieldsCanBeMergedRule.js +552 -354
  187. package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +545 -352
  188. package/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -4
  189. package/validation/rules/PossibleFragmentSpreadsRule.js +6 -4
  190. package/validation/rules/PossibleFragmentSpreadsRule.mjs +6 -4
  191. package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -4
  192. package/validation/rules/ProvidedRequiredArgumentsRule.js +6 -4
  193. package/validation/rules/ProvidedRequiredArgumentsRule.mjs +6 -4
  194. package/validation/rules/ScalarLeafsRule.d.ts +1 -3
  195. package/validation/rules/ScalarLeafsRule.js +1 -3
  196. package/validation/rules/ScalarLeafsRule.mjs +1 -3
  197. package/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -4
  198. package/validation/rules/SingleFieldSubscriptionsRule.js +50 -9
  199. package/validation/rules/SingleFieldSubscriptionsRule.mjs +50 -9
  200. package/validation/rules/UniqueArgumentNamesRule.d.ts +4 -4
  201. package/validation/rules/UniqueArgumentNamesRule.js +4 -4
  202. package/validation/rules/UniqueArgumentNamesRule.mjs +4 -4
  203. package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -4
  204. package/validation/rules/UniqueDirectivesPerLocationRule.js +6 -4
  205. package/validation/rules/UniqueDirectivesPerLocationRule.mjs +6 -4
  206. package/validation/rules/UniqueFragmentNamesRule.d.ts +4 -4
  207. package/validation/rules/UniqueFragmentNamesRule.js +4 -4
  208. package/validation/rules/UniqueFragmentNamesRule.mjs +4 -4
  209. package/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -4
  210. package/validation/rules/UniqueInputFieldNamesRule.js +6 -4
  211. package/validation/rules/UniqueInputFieldNamesRule.mjs +6 -4
  212. package/validation/rules/UniqueOperationNamesRule.d.ts +4 -4
  213. package/validation/rules/UniqueOperationNamesRule.js +4 -4
  214. package/validation/rules/UniqueOperationNamesRule.mjs +4 -4
  215. package/validation/rules/UniqueVariableNamesRule.d.ts +4 -4
  216. package/validation/rules/UniqueVariableNamesRule.js +4 -4
  217. package/validation/rules/UniqueVariableNamesRule.mjs +4 -4
  218. package/validation/rules/ValuesOfCorrectTypeRule.d.ts +4 -4
  219. package/validation/rules/ValuesOfCorrectTypeRule.js +29 -23
  220. package/validation/rules/ValuesOfCorrectTypeRule.mjs +24 -14
  221. package/validation/rules/VariablesAreInputTypesRule.d.ts +6 -4
  222. package/validation/rules/VariablesAreInputTypesRule.js +6 -4
  223. package/validation/rules/VariablesAreInputTypesRule.mjs +6 -4
  224. package/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -4
  225. package/validation/rules/VariablesInAllowedPositionRule.js +6 -4
  226. package/validation/rules/VariablesInAllowedPositionRule.mjs +6 -4
  227. package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +4 -4
  228. package/validation/rules/custom/NoDeprecatedCustomRule.js +4 -4
  229. package/validation/rules/custom/NoDeprecatedCustomRule.mjs +4 -4
  230. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +7 -5
  231. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +7 -5
  232. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +7 -5
  233. package/validation/validate.d.ts +2 -0
  234. package/validation/validate.js +14 -2
  235. package/validation/validate.mjs +13 -2
  236. package/validation/validationAbortedError.d.ts +3 -0
  237. package/validation/validationAbortedError.js +14 -0
  238. package/validation/validationAbortedError.mjs +4 -0
  239. package/version.js +3 -3
  240. package/version.mjs +3 -3
@@ -32,6 +32,7 @@ var _definition = require('../type/definition.js');
32
32
  * @param inputValue - JavaScript value to coerce.
33
33
  * @param type - GraphQL input type to coerce the value against.
34
34
  * @param onError - Callback invoked for each coercion error.
35
+ * @param hideSuggestions - Omit suggestions from error messages.
35
36
  * @returns Coerced value, or undefined if coercion failed and errors were reported.
36
37
  * @example
37
38
  * ```ts
@@ -53,7 +54,7 @@ var _definition = require('../type/definition.js');
53
54
  * },
54
55
  * });
55
56
  *
56
- * coerceInputValue({ stars: '5', tags: ['featured'] }, ReviewInput); // => { stars: 5, tags: ['featured'] }
57
+ * coerceInputValue({ stars: 5, tags: ['featured'] }, ReviewInput); // => { stars: 5, tags: ['featured'] }
57
58
  * coerceInputValue({ stars: 'bad' }, ReviewInput); // throws an error
58
59
  * ```
59
60
  * @example
@@ -62,7 +63,11 @@ var _definition = require('../type/definition.js');
62
63
  * import { GraphQLInt, GraphQLNonNull } from 'graphql/type';
63
64
  * import { coerceInputValue } from 'graphql/utilities';
64
65
  *
65
- * const errors = [];
66
+ * const errors: Array<{
67
+ * path: ReadonlyArray<string | number>;
68
+ * invalidValue: unknown;
69
+ * message: string;
70
+ * }> = [];
66
71
  * const value = coerceInputValue(
67
72
  * null,
68
73
  * new GraphQLNonNull(GraphQLInt),
@@ -75,8 +80,19 @@ var _definition = require('../type/definition.js');
75
80
  * errors; // => [ { path: [], invalidValue: null, message: 'Expected non-nullable type "Int!" not to be null.' } ]
76
81
  * ```
77
82
  */
78
- function coerceInputValue(inputValue, type, onError = defaultOnError) {
79
- return coerceInputValueImpl(inputValue, type, onError, undefined);
83
+ function coerceInputValue(
84
+ inputValue,
85
+ type,
86
+ onError = defaultOnError,
87
+ hideSuggestions,
88
+ ) {
89
+ return coerceInputValueImpl(
90
+ inputValue,
91
+ type,
92
+ onError,
93
+ undefined,
94
+ hideSuggestions,
95
+ );
80
96
  }
81
97
 
82
98
  function defaultOnError(path, invalidValue, error) {
@@ -90,10 +106,22 @@ function defaultOnError(path, invalidValue, error) {
90
106
  throw error;
91
107
  }
92
108
 
93
- function coerceInputValueImpl(inputValue, type, onError, path) {
109
+ function coerceInputValueImpl(
110
+ inputValue,
111
+ type,
112
+ onError,
113
+ path,
114
+ hideSuggestions,
115
+ ) {
94
116
  if ((0, _definition.isNonNullType)(type)) {
95
117
  if (inputValue != null) {
96
- return coerceInputValueImpl(inputValue, type.ofType, onError, path);
118
+ return coerceInputValueImpl(
119
+ inputValue,
120
+ type.ofType,
121
+ onError,
122
+ path,
123
+ hideSuggestions,
124
+ );
97
125
  }
98
126
 
99
127
  onError(
@@ -119,11 +147,25 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
119
147
  if ((0, _isIterableObject.isIterableObject)(inputValue)) {
120
148
  return Array.from(inputValue, (itemValue, index) => {
121
149
  const itemPath = (0, _Path.addPath)(path, index, undefined);
122
- return coerceInputValueImpl(itemValue, itemType, onError, itemPath);
150
+ return coerceInputValueImpl(
151
+ itemValue,
152
+ itemType,
153
+ onError,
154
+ itemPath,
155
+ hideSuggestions,
156
+ );
123
157
  });
124
158
  } // Lists accept a non-list value as a list of one.
125
159
 
126
- return [coerceInputValueImpl(inputValue, itemType, onError, path)];
160
+ return [
161
+ coerceInputValueImpl(
162
+ inputValue,
163
+ itemType,
164
+ onError,
165
+ path,
166
+ hideSuggestions,
167
+ ),
168
+ ];
127
169
  }
128
170
 
129
171
  if ((0, _definition.isInputObjectType)(type)) {
@@ -169,15 +211,18 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
169
211
  field.type,
170
212
  onError,
171
213
  (0, _Path.addPath)(path, field.name, type.name),
214
+ hideSuggestions,
172
215
  );
173
216
  } // Ensure every provided field is defined.
174
217
 
175
218
  for (const fieldName of Object.keys(inputValue)) {
176
219
  if (!fieldDefs[fieldName]) {
177
- const suggestions = (0, _suggestionList.suggestionList)(
178
- fieldName,
179
- Object.keys(type.getFields()),
180
- );
220
+ const suggestions = hideSuggestions
221
+ ? []
222
+ : (0, _suggestionList.suggestionList)(
223
+ fieldName,
224
+ Object.keys(type.getFields()),
225
+ );
181
226
  onError(
182
227
  (0, _Path.pathToArray)(path),
183
228
  inputValue,
@@ -223,7 +268,9 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
223
268
  // to the original error.
224
269
 
225
270
  try {
226
- parseResult = type.parseValue(inputValue);
271
+ parseResult = (0, _definition.isEnumType)(type)
272
+ ? type.parseValue(inputValue, hideSuggestions)
273
+ : type.parseValue(inputValue);
227
274
  } catch (error) {
228
275
  if (error instanceof _GraphQLError.GraphQLError) {
229
276
  onError((0, _Path.pathToArray)(path), inputValue, error);
@@ -9,6 +9,7 @@ import { printPathArray } from '../jsutils/printPathArray.mjs';
9
9
  import { suggestionList } from '../jsutils/suggestionList.mjs';
10
10
  import { GraphQLError } from '../error/GraphQLError.mjs';
11
11
  import {
12
+ isEnumType,
12
13
  isInputObjectType,
13
14
  isLeafType,
14
15
  isListType,
@@ -20,6 +21,7 @@ import {
20
21
  * @param inputValue - JavaScript value to coerce.
21
22
  * @param type - GraphQL input type to coerce the value against.
22
23
  * @param onError - Callback invoked for each coercion error.
24
+ * @param hideSuggestions - Omit suggestions from error messages.
23
25
  * @returns Coerced value, or undefined if coercion failed and errors were reported.
24
26
  * @example
25
27
  * ```ts
@@ -41,7 +43,7 @@ import {
41
43
  * },
42
44
  * });
43
45
  *
44
- * coerceInputValue({ stars: '5', tags: ['featured'] }, ReviewInput); // => { stars: 5, tags: ['featured'] }
46
+ * coerceInputValue({ stars: 5, tags: ['featured'] }, ReviewInput); // => { stars: 5, tags: ['featured'] }
45
47
  * coerceInputValue({ stars: 'bad' }, ReviewInput); // throws an error
46
48
  * ```
47
49
  * @example
@@ -50,7 +52,11 @@ import {
50
52
  * import { GraphQLInt, GraphQLNonNull } from 'graphql/type';
51
53
  * import { coerceInputValue } from 'graphql/utilities';
52
54
  *
53
- * const errors = [];
55
+ * const errors: Array<{
56
+ * path: ReadonlyArray<string | number>;
57
+ * invalidValue: unknown;
58
+ * message: string;
59
+ * }> = [];
54
60
  * const value = coerceInputValue(
55
61
  * null,
56
62
  * new GraphQLNonNull(GraphQLInt),
@@ -63,8 +69,19 @@ import {
63
69
  * errors; // => [ { path: [], invalidValue: null, message: 'Expected non-nullable type "Int!" not to be null.' } ]
64
70
  * ```
65
71
  */
66
- export function coerceInputValue(inputValue, type, onError = defaultOnError) {
67
- return coerceInputValueImpl(inputValue, type, onError, undefined);
72
+ export function coerceInputValue(
73
+ inputValue,
74
+ type,
75
+ onError = defaultOnError,
76
+ hideSuggestions,
77
+ ) {
78
+ return coerceInputValueImpl(
79
+ inputValue,
80
+ type,
81
+ onError,
82
+ undefined,
83
+ hideSuggestions,
84
+ );
68
85
  }
69
86
 
70
87
  function defaultOnError(path, invalidValue, error) {
@@ -78,10 +95,22 @@ function defaultOnError(path, invalidValue, error) {
78
95
  throw error;
79
96
  }
80
97
 
81
- function coerceInputValueImpl(inputValue, type, onError, path) {
98
+ function coerceInputValueImpl(
99
+ inputValue,
100
+ type,
101
+ onError,
102
+ path,
103
+ hideSuggestions,
104
+ ) {
82
105
  if (isNonNullType(type)) {
83
106
  if (inputValue != null) {
84
- return coerceInputValueImpl(inputValue, type.ofType, onError, path);
107
+ return coerceInputValueImpl(
108
+ inputValue,
109
+ type.ofType,
110
+ onError,
111
+ path,
112
+ hideSuggestions,
113
+ );
85
114
  }
86
115
 
87
116
  onError(
@@ -105,11 +134,25 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
105
134
  if (isIterableObject(inputValue)) {
106
135
  return Array.from(inputValue, (itemValue, index) => {
107
136
  const itemPath = addPath(path, index, undefined);
108
- return coerceInputValueImpl(itemValue, itemType, onError, itemPath);
137
+ return coerceInputValueImpl(
138
+ itemValue,
139
+ itemType,
140
+ onError,
141
+ itemPath,
142
+ hideSuggestions,
143
+ );
109
144
  });
110
145
  } // Lists accept a non-list value as a list of one.
111
146
 
112
- return [coerceInputValueImpl(inputValue, itemType, onError, path)];
147
+ return [
148
+ coerceInputValueImpl(
149
+ inputValue,
150
+ itemType,
151
+ onError,
152
+ path,
153
+ hideSuggestions,
154
+ ),
155
+ ];
113
156
  }
114
157
 
115
158
  if (isInputObjectType(type)) {
@@ -150,15 +193,15 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
150
193
  field.type,
151
194
  onError,
152
195
  addPath(path, field.name, type.name),
196
+ hideSuggestions,
153
197
  );
154
198
  } // Ensure every provided field is defined.
155
199
 
156
200
  for (const fieldName of Object.keys(inputValue)) {
157
201
  if (!fieldDefs[fieldName]) {
158
- const suggestions = suggestionList(
159
- fieldName,
160
- Object.keys(type.getFields()),
161
- );
202
+ const suggestions = hideSuggestions
203
+ ? []
204
+ : suggestionList(fieldName, Object.keys(type.getFields()));
162
205
  onError(
163
206
  pathToArray(path),
164
207
  inputValue,
@@ -204,7 +247,9 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
204
247
  // to the original error.
205
248
 
206
249
  try {
207
- parseResult = type.parseValue(inputValue);
250
+ parseResult = isEnumType(type)
251
+ ? type.parseValue(inputValue, hideSuggestions)
252
+ : type.parseValue(inputValue);
208
253
  } catch (error) {
209
254
  if (error instanceof GraphQLError) {
210
255
  onError(pathToArray(path), inputValue, error);
@@ -11,7 +11,10 @@ import type { DocumentNode } from '../language/ast';
11
11
  * import { parse } from 'graphql/language';
12
12
  * import { concatAST } from 'graphql/utilities';
13
13
  *
14
- * const document = concatAST([parse('type Query { a: String }'), parse('type User { id: ID }')]);
14
+ * const document = concatAST([
15
+ * parse('type Query { a: String }'),
16
+ * parse('type User { id: ID }'),
17
+ * ]);
15
18
  *
16
19
  * document.definitions.length; // => 2
17
20
  * ```
@@ -20,7 +20,10 @@ var _kinds = require('../language/kinds.js');
20
20
  * import { parse } from 'graphql/language';
21
21
  * import { concatAST } from 'graphql/utilities';
22
22
  *
23
- * const document = concatAST([parse('type Query { a: String }'), parse('type User { id: ID }')]);
23
+ * const document = concatAST([
24
+ * parse('type Query { a: String }'),
25
+ * parse('type User { id: ID }'),
26
+ * ]);
24
27
  *
25
28
  * document.definitions.length; // => 2
26
29
  * ```
@@ -11,7 +11,10 @@ import { Kind } from '../language/kinds.mjs';
11
11
  * import { parse } from 'graphql/language';
12
12
  * import { concatAST } from 'graphql/utilities';
13
13
  *
14
- * const document = concatAST([parse('type Query { a: String }'), parse('type User { id: ID }')]);
14
+ * const document = concatAST([
15
+ * parse('type Query { a: String }'),
16
+ * parse('type User { id: ID }'),
17
+ * ]);
15
18
  *
16
19
  * document.definitions.length; // => 2
17
20
  * ```
@@ -31,6 +31,7 @@ interface Options extends GraphQLSchemaValidationOptions {
31
31
  * @example
32
32
  * ```ts
33
33
  * // Extend a schema with new fields and types.
34
+ * import assert from 'node:assert/strict';
34
35
  * import { parse } from 'graphql/language';
35
36
  * import { buildSchema, extendSchema } from 'graphql/utilities';
36
37
  *
@@ -53,7 +54,9 @@ interface Options extends GraphQLSchemaValidationOptions {
53
54
  *
54
55
  * schema.getType('Review'); // => undefined
55
56
  * extendedSchema.getType('Review')?.name; // => 'Review'
56
- * Object.keys(extendedSchema.getQueryType().getFields()); // => ['greeting', 'farewell']
57
+ * const queryType = extendedSchema.getQueryType();
58
+ * assert(queryType);
59
+ * Object.keys(queryType.getFields()); // => ['greeting', 'farewell']
57
60
  * ```
58
61
  * @example
59
62
  * ```ts
@@ -74,9 +77,9 @@ interface Options extends GraphQLSchemaValidationOptions {
74
77
  *
75
78
  * extendSchema(schema, invalidExtension); // throws an error
76
79
  * extendSchema(schema, invalidExtension, {
77
- * assumeValid: true,
78
- * assumeValidSDL: true,
79
- * }); // does not throw
80
+ * assumeValid: true,
81
+ * assumeValidSDL: true,
82
+ * }); // does not throw
80
83
  * ```
81
84
  */
82
85
  export declare function extendSchema(
@@ -56,6 +56,7 @@ var _valueFromAST = require('./valueFromAST.js');
56
56
  * @example
57
57
  * ```ts
58
58
  * // Extend a schema with new fields and types.
59
+ * import assert from 'node:assert/strict';
59
60
  * import { parse } from 'graphql/language';
60
61
  * import { buildSchema, extendSchema } from 'graphql/utilities';
61
62
  *
@@ -78,7 +79,9 @@ var _valueFromAST = require('./valueFromAST.js');
78
79
  *
79
80
  * schema.getType('Review'); // => undefined
80
81
  * extendedSchema.getType('Review')?.name; // => 'Review'
81
- * Object.keys(extendedSchema.getQueryType().getFields()); // => ['greeting', 'farewell']
82
+ * const queryType = extendedSchema.getQueryType();
83
+ * assert(queryType);
84
+ * Object.keys(queryType.getFields()); // => ['greeting', 'farewell']
82
85
  * ```
83
86
  * @example
84
87
  * ```ts
@@ -99,9 +102,9 @@ var _valueFromAST = require('./valueFromAST.js');
99
102
  *
100
103
  * extendSchema(schema, invalidExtension); // throws an error
101
104
  * extendSchema(schema, invalidExtension, {
102
- * assumeValid: true,
103
- * assumeValidSDL: true,
104
- * }); // does not throw
105
+ * assumeValid: true,
106
+ * assumeValidSDL: true,
107
+ * }); // does not throw
105
108
  * ```
106
109
  */
107
110
  function extendSchema(schema, documentAST, options) {
@@ -64,6 +64,7 @@ import { valueFromAST } from './valueFromAST.mjs';
64
64
  * @example
65
65
  * ```ts
66
66
  * // Extend a schema with new fields and types.
67
+ * import assert from 'node:assert/strict';
67
68
  * import { parse } from 'graphql/language';
68
69
  * import { buildSchema, extendSchema } from 'graphql/utilities';
69
70
  *
@@ -86,7 +87,9 @@ import { valueFromAST } from './valueFromAST.mjs';
86
87
  *
87
88
  * schema.getType('Review'); // => undefined
88
89
  * extendedSchema.getType('Review')?.name; // => 'Review'
89
- * Object.keys(extendedSchema.getQueryType().getFields()); // => ['greeting', 'farewell']
90
+ * const queryType = extendedSchema.getQueryType();
91
+ * assert(queryType);
92
+ * Object.keys(queryType.getFields()); // => ['greeting', 'farewell']
90
93
  * ```
91
94
  * @example
92
95
  * ```ts
@@ -107,9 +110,9 @@ import { valueFromAST } from './valueFromAST.mjs';
107
110
  *
108
111
  * extendSchema(schema, invalidExtension); // throws an error
109
112
  * extendSchema(schema, invalidExtension, {
110
- * assumeValid: true,
111
- * assumeValidSDL: true,
112
- * }); // does not throw
113
+ * assumeValid: true,
114
+ * assumeValidSDL: true,
115
+ * }); // does not throw
113
116
  * ```
114
117
  */
115
118
  export function extendSchema(schema, documentAST, options) {
@@ -99,7 +99,7 @@ export interface DangerousChange {
99
99
  * const changes = findBreakingChanges(oldSchema, newSchema);
100
100
  *
101
101
  * changes[0].type; // => 'FIELD_REMOVED'
102
- * changes[0].description; // matches /User.name was removed/
102
+ * changes[0].description.includes('User.name was removed'); // => true
103
103
  * ```
104
104
  */
105
105
  export declare function findBreakingChanges(
@@ -139,7 +139,7 @@ export declare function findBreakingChanges(
139
139
  * const changes = findDangerousChanges(oldSchema, newSchema);
140
140
  *
141
141
  * changes[0].type; // => 'VALUE_ADDED_TO_ENUM'
142
- * changes[0].description; // matches /EMPIRE was added/
142
+ * changes[0].description.includes('EMPIRE was added'); // => true
143
143
  * ```
144
144
  */
145
145
  export declare function findDangerousChanges(
@@ -106,7 +106,7 @@ exports.DangerousChangeType = DangerousChangeType;
106
106
  * const changes = findBreakingChanges(oldSchema, newSchema);
107
107
  *
108
108
  * changes[0].type; // => 'FIELD_REMOVED'
109
- * changes[0].description; // matches /User.name was removed/
109
+ * changes[0].description.includes('User.name was removed'); // => true
110
110
  * ```
111
111
  */
112
112
  function findBreakingChanges(oldSchema, newSchema) {
@@ -148,7 +148,7 @@ function findBreakingChanges(oldSchema, newSchema) {
148
148
  * const changes = findDangerousChanges(oldSchema, newSchema);
149
149
  *
150
150
  * changes[0].type; // => 'VALUE_ADDED_TO_ENUM'
151
- * changes[0].description; // matches /EMPIRE was added/
151
+ * changes[0].description.includes('EMPIRE was added'); // => true
152
152
  * ```
153
153
  */
154
154
 
@@ -99,7 +99,7 @@ export { DangerousChangeType };
99
99
  * const changes = findBreakingChanges(oldSchema, newSchema);
100
100
  *
101
101
  * changes[0].type; // => 'FIELD_REMOVED'
102
- * changes[0].description; // matches /User.name was removed/
102
+ * changes[0].description.includes('User.name was removed'); // => true
103
103
  * ```
104
104
  */
105
105
  export function findBreakingChanges(oldSchema, newSchema) {
@@ -141,7 +141,7 @@ export function findBreakingChanges(oldSchema, newSchema) {
141
141
  * const changes = findDangerousChanges(oldSchema, newSchema);
142
142
  *
143
143
  * changes[0].type; // => 'VALUE_ADDED_TO_ENUM'
144
- * changes[0].description; // matches /EMPIRE was added/
144
+ * changes[0].description.includes('EMPIRE was added'); // => true
145
145
  * ```
146
146
  */
147
147
 
@@ -60,9 +60,9 @@ export interface IntrospectionOptions {
60
60
  *
61
61
  * const query = getIntrospectionQuery();
62
62
  *
63
- * query; // matches /__schema/
64
- * query; // matches /description/
65
- * query; // does not match /specifiedByURL/
63
+ * query.includes('__schema'); // => true
64
+ * query.includes('description'); // => true
65
+ * query.includes('specifiedByURL'); // => false
66
66
  * ```
67
67
  * @example
68
68
  * ```ts
@@ -80,11 +80,11 @@ export interface IntrospectionOptions {
80
80
  * typeDepth: 3,
81
81
  * });
82
82
  *
83
- * query; // does not match /description/
84
- * query; // matches /specifiedByURL/
85
- * query; // matches /isRepeatable/
86
- * query; // matches /includeDeprecated: true/
87
- * query; // matches /isOneOf/
83
+ * query.includes('description'); // => false
84
+ * query.includes('specifiedByURL'); // => true
85
+ * query.includes('isRepeatable'); // => true
86
+ * query.includes('includeDeprecated: true'); // => true
87
+ * query.includes('isOneOf'); // => true
88
88
  * (query.match(/ofType/g)?.length ?? 0) > 0; // => true
89
89
  * ```
90
90
  */
@@ -110,7 +110,7 @@ export interface IntrospectionSchema {
110
110
  readonly subscriptionType: Maybe<
111
111
  IntrospectionNamedTypeRef<IntrospectionObjectType>
112
112
  >;
113
- /** Object types that belong to this union type. */
113
+ /** All named types that belong to this schema. */
114
114
  readonly types: ReadonlyArray<IntrospectionType>;
115
115
  /** Directives available in this schema or applied to this AST node. */
116
116
  readonly directives: ReadonlyArray<IntrospectionDirective>;
@@ -21,9 +21,9 @@ exports.getIntrospectionQuery = getIntrospectionQuery;
21
21
  *
22
22
  * const query = getIntrospectionQuery();
23
23
  *
24
- * query; // matches /__schema/
25
- * query; // matches /description/
26
- * query; // does not match /specifiedByURL/
24
+ * query.includes('__schema'); // => true
25
+ * query.includes('description'); // => true
26
+ * query.includes('specifiedByURL'); // => false
27
27
  * ```
28
28
  * @example
29
29
  * ```ts
@@ -41,11 +41,11 @@ exports.getIntrospectionQuery = getIntrospectionQuery;
41
41
  * typeDepth: 3,
42
42
  * });
43
43
  *
44
- * query; // does not match /description/
45
- * query; // matches /specifiedByURL/
46
- * query; // matches /isRepeatable/
47
- * query; // matches /includeDeprecated: true/
48
- * query; // matches /isOneOf/
44
+ * query.includes('description'); // => false
45
+ * query.includes('specifiedByURL'); // => true
46
+ * query.includes('isRepeatable'); // => true
47
+ * query.includes('includeDeprecated: true'); // => true
48
+ * query.includes('isOneOf'); // => true
49
49
  * (query.match(/ofType/g)?.length ?? 0) > 0; // => true
50
50
  * ```
51
51
  */
@@ -14,9 +14,9 @@
14
14
  *
15
15
  * const query = getIntrospectionQuery();
16
16
  *
17
- * query; // matches /__schema/
18
- * query; // matches /description/
19
- * query; // does not match /specifiedByURL/
17
+ * query.includes('__schema'); // => true
18
+ * query.includes('description'); // => true
19
+ * query.includes('specifiedByURL'); // => false
20
20
  * ```
21
21
  * @example
22
22
  * ```ts
@@ -34,11 +34,11 @@
34
34
  * typeDepth: 3,
35
35
  * });
36
36
  *
37
- * query; // does not match /description/
38
- * query; // matches /specifiedByURL/
39
- * query; // matches /isRepeatable/
40
- * query; // matches /includeDeprecated: true/
41
- * query; // matches /isOneOf/
37
+ * query.includes('description'); // => false
38
+ * query.includes('specifiedByURL'); // => true
39
+ * query.includes('isRepeatable'); // => true
40
+ * query.includes('includeDeprecated: true'); // => true
41
+ * query.includes('isOneOf'); // => true
42
42
  * (query.match(/ofType/g)?.length ?? 0) > 0; // => true
43
43
  * ```
44
44
  */
@@ -16,8 +16,8 @@ import type { DocumentNode, OperationDefinitionNode } from '../language/ast';
16
16
  * const document = parse('query GetName { name }');
17
17
  * const operation = getOperationAST(document, 'GetName');
18
18
  *
19
- * operation.name.value; // => 'GetName'
20
- * getOperationAST(document, 'Missing'); // => undefined
19
+ * operation?.name?.value; // => 'GetName'
20
+ * getOperationAST(document, 'Missing'); // => null
21
21
  * ```
22
22
  */
23
23
  export declare function getOperationAST(
@@ -24,8 +24,8 @@ var _kinds = require('../language/kinds.js');
24
24
  * const document = parse('query GetName { name }');
25
25
  * const operation = getOperationAST(document, 'GetName');
26
26
  *
27
- * operation.name.value; // => 'GetName'
28
- * getOperationAST(document, 'Missing'); // => undefined
27
+ * operation?.name?.value; // => 'GetName'
28
+ * getOperationAST(document, 'Missing'); // => null
29
29
  * ```
30
30
  */
31
31
  function getOperationAST(documentAST, operationName) {
@@ -15,8 +15,8 @@ import { Kind } from '../language/kinds.mjs';
15
15
  * const document = parse('query GetName { name }');
16
16
  * const operation = getOperationAST(document, 'GetName');
17
17
  *
18
- * operation.name.value; // => 'GetName'
19
- * getOperationAST(document, 'Missing'); // => undefined
18
+ * operation?.name?.value; // => 'GetName'
19
+ * getOperationAST(document, 'Missing'); // => null
20
20
  * ```
21
21
  */
22
22
 
@@ -15,11 +15,13 @@ import type { GraphQLSchema } from '../type/schema';
15
15
  * @returns The resolved operation root type.
16
16
  * @example
17
17
  * ```ts
18
+ * import assert from 'node:assert/strict';
18
19
  * import { buildSchema, getOperationRootType } from 'graphql/utilities';
19
- * import { parse } from 'graphql/language';
20
+ * import { parse, Kind } from 'graphql/language';
20
21
  *
21
22
  * const schema = buildSchema('type Query { name: String }');
22
23
  * const operation = parse('{ name }').definitions[0];
24
+ * assert(operation.kind === Kind.OPERATION_DEFINITION);
23
25
  * const rootType = getOperationRootType(schema, operation);
24
26
  *
25
27
  * rootType.name; // => 'Query'
@@ -19,11 +19,13 @@ var _GraphQLError = require('../error/GraphQLError.js');
19
19
  * @returns The resolved operation root type.
20
20
  * @example
21
21
  * ```ts
22
+ * import assert from 'node:assert/strict';
22
23
  * import { buildSchema, getOperationRootType } from 'graphql/utilities';
23
- * import { parse } from 'graphql/language';
24
+ * import { parse, Kind } from 'graphql/language';
24
25
  *
25
26
  * const schema = buildSchema('type Query { name: String }');
26
27
  * const operation = parse('{ name }').definitions[0];
28
+ * assert(operation.kind === Kind.OPERATION_DEFINITION);
27
29
  * const rootType = getOperationRootType(schema, operation);
28
30
  *
29
31
  * rootType.name; // => 'Query'
@@ -11,11 +11,13 @@ import { GraphQLError } from '../error/GraphQLError.mjs';
11
11
  * @returns The resolved operation root type.
12
12
  * @example
13
13
  * ```ts
14
+ * import assert from 'node:assert/strict';
14
15
  * import { buildSchema, getOperationRootType } from 'graphql/utilities';
15
- * import { parse } from 'graphql/language';
16
+ * import { parse, Kind } from 'graphql/language';
16
17
  *
17
18
  * const schema = buildSchema('type Query { name: String }');
18
19
  * const operation = parse('{ name }').definitions[0];
20
+ * assert(operation.kind === Kind.OPERATION_DEFINITION);
19
21
  * const rootType = getOperationRootType(schema, operation);
20
22
  *
21
23
  * rootType.name; // => 'Query'