graphql 16.14.1 → 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 +190 -122
  68. package/type/definition.js +175 -102
  69. package/type/definition.mjs +174 -101
  70. package/type/directives.d.ts +14 -8
  71. package/type/directives.js +13 -7
  72. package/type/directives.mjs +13 -7
  73. package/type/scalars.js +8 -11
  74. package/type/scalars.mjs +1 -1
  75. package/type/schema.d.ts +38 -13
  76. package/type/schema.js +36 -11
  77. package/type/schema.mjs +36 -11
  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
@@ -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'
@@ -17,6 +17,7 @@ import type {
17
17
  * @returns Introspection result data for the schema.
18
18
  * @example
19
19
  * ```ts
20
+ * import assert from 'node:assert/strict';
20
21
  * // Include schema metadata using the default introspection options.
21
22
  * import { buildSchema, introspectionFromSchema } from 'graphql/utilities';
22
23
  *
@@ -29,12 +30,16 @@ import type {
29
30
  * `);
30
31
  *
31
32
  * const introspection = introspectionFromSchema(schema);
32
- * const urlType = introspection.__schema.types.find((type) => type.name === 'Url');
33
+ * const urlType = introspection.__schema.types.find(
34
+ * (type) => type.name === 'Url',
35
+ * );
36
+ * assert(urlType?.kind === 'SCALAR');
33
37
  *
34
38
  * urlType.specifiedByURL; // => 'https://url.spec.whatwg.org/'
35
39
  * ```
36
40
  * @example
37
41
  * ```ts
42
+ * import assert from 'node:assert/strict';
38
43
  * // This variant disables optional introspection metadata.
39
44
  * import { buildSchema, introspectionFromSchema } from 'graphql/utilities';
40
45
  *
@@ -55,15 +60,18 @@ import type {
55
60
  * experimentalDirectiveDeprecation: false,
56
61
  * oneOf: false,
57
62
  * });
58
- * const urlType = introspection.__schema.types.find((type) => type.name === 'Url');
63
+ * const urlType = introspection.__schema.types.find(
64
+ * (type) => type.name === 'Url',
65
+ * );
66
+ * assert(urlType?.kind === 'SCALAR');
59
67
  * const deprecatedDirective = introspection.__schema.directives.find(
60
68
  * (directive) => directive.name === 'deprecated',
61
69
  * );
62
70
  *
63
- * urlType.specifiedByURL; // => undefined
64
71
  * urlType.description; // => undefined
72
+ * urlType.specifiedByURL; // => undefined
73
+ * deprecatedDirective?.isRepeatable; // => undefined
65
74
  * introspection.__schema.description; // => undefined
66
- * deprecatedDirective.isRepeatable; // => undefined
67
75
  * ```
68
76
  */
69
77
  export declare function introspectionFromSchema(
@@ -28,6 +28,7 @@ var _getIntrospectionQuery = require('./getIntrospectionQuery.js');
28
28
  * @returns Introspection result data for the schema.
29
29
  * @example
30
30
  * ```ts
31
+ * import assert from 'node:assert/strict';
31
32
  * // Include schema metadata using the default introspection options.
32
33
  * import { buildSchema, introspectionFromSchema } from 'graphql/utilities';
33
34
  *
@@ -40,12 +41,16 @@ var _getIntrospectionQuery = require('./getIntrospectionQuery.js');
40
41
  * `);
41
42
  *
42
43
  * const introspection = introspectionFromSchema(schema);
43
- * const urlType = introspection.__schema.types.find((type) => type.name === 'Url');
44
+ * const urlType = introspection.__schema.types.find(
45
+ * (type) => type.name === 'Url',
46
+ * );
47
+ * assert(urlType?.kind === 'SCALAR');
44
48
  *
45
49
  * urlType.specifiedByURL; // => 'https://url.spec.whatwg.org/'
46
50
  * ```
47
51
  * @example
48
52
  * ```ts
53
+ * import assert from 'node:assert/strict';
49
54
  * // This variant disables optional introspection metadata.
50
55
  * import { buildSchema, introspectionFromSchema } from 'graphql/utilities';
51
56
  *
@@ -66,15 +71,18 @@ var _getIntrospectionQuery = require('./getIntrospectionQuery.js');
66
71
  * experimentalDirectiveDeprecation: false,
67
72
  * oneOf: false,
68
73
  * });
69
- * const urlType = introspection.__schema.types.find((type) => type.name === 'Url');
74
+ * const urlType = introspection.__schema.types.find(
75
+ * (type) => type.name === 'Url',
76
+ * );
77
+ * assert(urlType?.kind === 'SCALAR');
70
78
  * const deprecatedDirective = introspection.__schema.directives.find(
71
79
  * (directive) => directive.name === 'deprecated',
72
80
  * );
73
81
  *
74
- * urlType.specifiedByURL; // => undefined
75
82
  * urlType.description; // => undefined
83
+ * urlType.specifiedByURL; // => undefined
84
+ * deprecatedDirective?.isRepeatable; // => undefined
76
85
  * introspection.__schema.description; // => undefined
77
- * deprecatedDirective.isRepeatable; // => undefined
78
86
  * ```
79
87
  */
80
88
  function introspectionFromSchema(schema, options) {
@@ -16,6 +16,7 @@ import { getIntrospectionQuery } from './getIntrospectionQuery.mjs';
16
16
  * @returns Introspection result data for the schema.
17
17
  * @example
18
18
  * ```ts
19
+ * import assert from 'node:assert/strict';
19
20
  * // Include schema metadata using the default introspection options.
20
21
  * import { buildSchema, introspectionFromSchema } from 'graphql/utilities';
21
22
  *
@@ -28,12 +29,16 @@ import { getIntrospectionQuery } from './getIntrospectionQuery.mjs';
28
29
  * `);
29
30
  *
30
31
  * const introspection = introspectionFromSchema(schema);
31
- * const urlType = introspection.__schema.types.find((type) => type.name === 'Url');
32
+ * const urlType = introspection.__schema.types.find(
33
+ * (type) => type.name === 'Url',
34
+ * );
35
+ * assert(urlType?.kind === 'SCALAR');
32
36
  *
33
37
  * urlType.specifiedByURL; // => 'https://url.spec.whatwg.org/'
34
38
  * ```
35
39
  * @example
36
40
  * ```ts
41
+ * import assert from 'node:assert/strict';
37
42
  * // This variant disables optional introspection metadata.
38
43
  * import { buildSchema, introspectionFromSchema } from 'graphql/utilities';
39
44
  *
@@ -54,15 +59,18 @@ import { getIntrospectionQuery } from './getIntrospectionQuery.mjs';
54
59
  * experimentalDirectiveDeprecation: false,
55
60
  * oneOf: false,
56
61
  * });
57
- * const urlType = introspection.__schema.types.find((type) => type.name === 'Url');
62
+ * const urlType = introspection.__schema.types.find(
63
+ * (type) => type.name === 'Url',
64
+ * );
65
+ * assert(urlType?.kind === 'SCALAR');
58
66
  * const deprecatedDirective = introspection.__schema.directives.find(
59
67
  * (directive) => directive.name === 'deprecated',
60
68
  * );
61
69
  *
62
- * urlType.specifiedByURL; // => undefined
63
70
  * urlType.description; // => undefined
71
+ * urlType.specifiedByURL; // => undefined
72
+ * deprecatedDirective?.isRepeatable; // => undefined
64
73
  * introspection.__schema.description; // => undefined
65
- * deprecatedDirective.isRepeatable; // => undefined
66
74
  * ```
67
75
  */
68
76
 
@@ -8,7 +8,11 @@ import { GraphQLSchema } from '../type/schema';
8
8
  * @returns A copy of the schema with types, fields, arguments, and values sorted lexicographically.
9
9
  * @example
10
10
  * ```ts
11
- * import { buildSchema, lexicographicSortSchema, printSchema } from 'graphql/utilities';
11
+ * import {
12
+ * buildSchema,
13
+ * lexicographicSortSchema,
14
+ * printSchema,
15
+ * } from 'graphql/utilities';
12
16
  *
13
17
  * const schema = buildSchema(`
14
18
  * type Query {
@@ -25,18 +29,18 @@ import { GraphQLSchema } from '../type/schema';
25
29
  *
26
30
  * const sortedSchema = lexicographicSortSchema(schema);
27
31
  *
28
- * printSchema(sortedSchema);
29
- * // =>
30
- * // enum Episode {
31
- * // EMPIRE
32
- * // JEDI
33
- * // NEW_HOPE
34
- * // }
35
- * //
36
- * // type Query {
37
- * // apple: String
38
- * // zebra: String
39
- * // }
32
+ * const expectedSDL = `enum Episode {
33
+ * EMPIRE
34
+ * JEDI
35
+ * NEW_HOPE
36
+ * }
37
+ *
38
+ * type Query {
39
+ * apple: String
40
+ * zebra: String
41
+ * }`;
42
+ *
43
+ * printSchema(sortedSchema); // => expectedSDL
40
44
  * ```
41
45
  */
42
46
  export declare function lexicographicSortSchema(
@@ -31,7 +31,11 @@ var _schema = require('../type/schema.js');
31
31
  * @returns A copy of the schema with types, fields, arguments, and values sorted lexicographically.
32
32
  * @example
33
33
  * ```ts
34
- * import { buildSchema, lexicographicSortSchema, printSchema } from 'graphql/utilities';
34
+ * import {
35
+ * buildSchema,
36
+ * lexicographicSortSchema,
37
+ * printSchema,
38
+ * } from 'graphql/utilities';
35
39
  *
36
40
  * const schema = buildSchema(`
37
41
  * type Query {
@@ -48,18 +52,18 @@ var _schema = require('../type/schema.js');
48
52
  *
49
53
  * const sortedSchema = lexicographicSortSchema(schema);
50
54
  *
51
- * printSchema(sortedSchema);
52
- * // =>
53
- * // enum Episode {
54
- * // EMPIRE
55
- * // JEDI
56
- * // NEW_HOPE
57
- * // }
58
- * //
59
- * // type Query {
60
- * // apple: String
61
- * // zebra: String
62
- * // }
55
+ * const expectedSDL = `enum Episode {
56
+ * EMPIRE
57
+ * JEDI
58
+ * NEW_HOPE
59
+ * }
60
+ *
61
+ * type Query {
62
+ * apple: String
63
+ * zebra: String
64
+ * }`;
65
+ *
66
+ * printSchema(sortedSchema); // => expectedSDL
63
67
  * ```
64
68
  */
65
69
  function lexicographicSortSchema(schema) {
@@ -31,7 +31,11 @@ import { GraphQLSchema } from '../type/schema.mjs';
31
31
  * @returns A copy of the schema with types, fields, arguments, and values sorted lexicographically.
32
32
  * @example
33
33
  * ```ts
34
- * import { buildSchema, lexicographicSortSchema, printSchema } from 'graphql/utilities';
34
+ * import {
35
+ * buildSchema,
36
+ * lexicographicSortSchema,
37
+ * printSchema,
38
+ * } from 'graphql/utilities';
35
39
  *
36
40
  * const schema = buildSchema(`
37
41
  * type Query {
@@ -48,18 +52,18 @@ import { GraphQLSchema } from '../type/schema.mjs';
48
52
  *
49
53
  * const sortedSchema = lexicographicSortSchema(schema);
50
54
  *
51
- * printSchema(sortedSchema);
52
- * // =>
53
- * // enum Episode {
54
- * // EMPIRE
55
- * // JEDI
56
- * // NEW_HOPE
57
- * // }
58
- * //
59
- * // type Query {
60
- * // apple: String
61
- * // zebra: String
62
- * // }
55
+ * const expectedSDL = `enum Episode {
56
+ * EMPIRE
57
+ * JEDI
58
+ * NEW_HOPE
59
+ * }
60
+ *
61
+ * type Query {
62
+ * apple: String
63
+ * zebra: String
64
+ * }`;
65
+ *
66
+ * printSchema(sortedSchema); // => expectedSDL
63
67
  * ```
64
68
  */
65
69
 
@@ -37,9 +37,9 @@ export declare function printSchema(schema: GraphQLSchema): string;
37
37
  *
38
38
  * const printed = printIntrospectionSchema(schema);
39
39
  *
40
- * printed; // matches /type __Schema/
41
- * printed; // matches /enum __TypeKind/
42
- * printed; // does not match /type Query/
40
+ * printed.includes('type __Schema'); // => true
41
+ * printed.includes('enum __TypeKind'); // => true
42
+ * printed.includes('type Query'); // => false
43
43
  * ```
44
44
  */
45
45
  export declare function printIntrospectionSchema(schema: GraphQLSchema): string;
@@ -49,6 +49,7 @@ export declare function printIntrospectionSchema(schema: GraphQLSchema): string;
49
49
  * @returns The printed string representation.
50
50
  * @example
51
51
  * ```ts
52
+ * import assert from 'node:assert/strict';
52
53
  * import { buildSchema, printType } from 'graphql/utilities';
53
54
  *
54
55
  * const schema = buildSchema(`
@@ -62,7 +63,9 @@ export declare function printIntrospectionSchema(schema: GraphQLSchema): string;
62
63
  * }
63
64
  * `);
64
65
  *
65
- * printType(schema.getType('User')); // => ['type User {', ' id: ID!', ' name: String', '}'].join('\n')
66
+ * const userType = schema.getType('User');
67
+ * assert(userType);
68
+ * printType(userType); // => ['type User {', ' id: ID!', ' name: String', '}'].join('\n')
66
69
  * ```
67
70
  */
68
71
  export declare function printType(type: GraphQLNamedType): string;
@@ -71,9 +71,9 @@ function printSchema(schema) {
71
71
  *
72
72
  * const printed = printIntrospectionSchema(schema);
73
73
  *
74
- * printed; // matches /type __Schema/
75
- * printed; // matches /enum __TypeKind/
76
- * printed; // does not match /type Query/
74
+ * printed.includes('type __Schema'); // => true
75
+ * printed.includes('enum __TypeKind'); // => true
76
+ * printed.includes('type Query'); // => false
77
77
  * ```
78
78
  */
79
79
 
@@ -175,6 +175,7 @@ function isSchemaOfCommonNames(schema) {
175
175
  * @returns The printed string representation.
176
176
  * @example
177
177
  * ```ts
178
+ * import assert from 'node:assert/strict';
178
179
  * import { buildSchema, printType } from 'graphql/utilities';
179
180
  *
180
181
  * const schema = buildSchema(`
@@ -188,7 +189,9 @@ function isSchemaOfCommonNames(schema) {
188
189
  * }
189
190
  * `);
190
191
  *
191
- * printType(schema.getType('User')); // => ['type User {', ' id: ID!', ' name: String', '}'].join('\n')
192
+ * const userType = schema.getType('User');
193
+ * assert(userType);
194
+ * printType(userType); // => ['type User {', ' id: ID!', ' name: String', '}'].join('\n')
192
195
  * ```
193
196
  */
194
197
 
@@ -62,9 +62,9 @@ export function printSchema(schema) {
62
62
  *
63
63
  * const printed = printIntrospectionSchema(schema);
64
64
  *
65
- * printed; // matches /type __Schema/
66
- * printed; // matches /enum __TypeKind/
67
- * printed; // does not match /type Query/
65
+ * printed.includes('type __Schema'); // => true
66
+ * printed.includes('enum __TypeKind'); // => true
67
+ * printed.includes('type Query'); // => false
68
68
  * ```
69
69
  */
70
70
 
@@ -159,6 +159,7 @@ function isSchemaOfCommonNames(schema) {
159
159
  * @returns The printed string representation.
160
160
  * @example
161
161
  * ```ts
162
+ * import assert from 'node:assert/strict';
162
163
  * import { buildSchema, printType } from 'graphql/utilities';
163
164
  *
164
165
  * const schema = buildSchema(`
@@ -172,7 +173,9 @@ function isSchemaOfCommonNames(schema) {
172
173
  * }
173
174
  * `);
174
175
  *
175
- * printType(schema.getType('User')); // => ['type User {', ' id: ID!', ' name: String', '}'].join('\n')
176
+ * const userType = schema.getType('User');
177
+ * assert(userType);
178
+ * printType(userType); // => ['type User {', ' id: ID!', ' name: String', '}'].join('\n')
176
179
  * ```
177
180
  */
178
181
 
@@ -99,13 +99,13 @@ export declare type ResolvedSchemaElement =
99
99
  * }
100
100
  * `);
101
101
  *
102
- * resolveSchemaCoordinate(schema, 'Query').kind; // => 'NamedType'
103
- * resolveSchemaCoordinate(schema, 'Query.reviews').kind; // => 'Field'
104
- * resolveSchemaCoordinate(schema, 'Query.reviews(input:)').kind; // => 'FieldArgument'
105
- * resolveSchemaCoordinate(schema, 'ReviewInput.stars').kind; // => 'InputField'
106
- * resolveSchemaCoordinate(schema, 'Episode.NEW_HOPE').kind; // => 'EnumValue'
107
- * resolveSchemaCoordinate(schema, '@tag').kind; // => 'Directive'
108
- * resolveSchemaCoordinate(schema, '@tag(name:)').kind; // => 'DirectiveArgument'
102
+ * resolveSchemaCoordinate(schema, 'Query')?.kind; // => 'NamedType'
103
+ * resolveSchemaCoordinate(schema, 'Query.reviews')?.kind; // => 'Field'
104
+ * resolveSchemaCoordinate(schema, 'Query.reviews(input:)')?.kind; // => 'FieldArgument'
105
+ * resolveSchemaCoordinate(schema, 'ReviewInput.stars')?.kind; // => 'InputField'
106
+ * resolveSchemaCoordinate(schema, 'Episode.NEW_HOPE')?.kind; // => 'EnumValue'
107
+ * resolveSchemaCoordinate(schema, '@tag')?.kind; // => 'Directive'
108
+ * resolveSchemaCoordinate(schema, '@tag(name:)')?.kind; // => 'DirectiveArgument'
109
109
  * resolveSchemaCoordinate(schema, 'Query.missing'); // => undefined
110
110
  * ```
111
111
  */
@@ -120,6 +120,7 @@ export declare function resolveSchemaCoordinate(
120
120
  * @returns The schema element identified by the parsed coordinate, or undefined if none exists.
121
121
  * @example
122
122
  * ```ts
123
+ * import assert from 'node:assert/strict';
123
124
  * import { parseSchemaCoordinate } from 'graphql/language';
124
125
  * import { buildSchema, resolveASTSchemaCoordinate } from 'graphql/utilities';
125
126
  *
@@ -131,7 +132,7 @@ export declare function resolveSchemaCoordinate(
131
132
  * const coordinate = parseSchemaCoordinate('Query.greeting(name:)');
132
133
  * const resolved = resolveASTSchemaCoordinate(schema, coordinate);
133
134
  *
134
- * resolved.kind; // => 'FieldArgument'
135
+ * assert(resolved?.kind === 'FieldArgument');
135
136
  * resolved.field.name; // => 'greeting'
136
137
  * resolved.fieldArgument.name; // => 'name'
137
138
  * ```
@@ -47,13 +47,13 @@ var _definition = require('../type/definition.js');
47
47
  * }
48
48
  * `);
49
49
  *
50
- * resolveSchemaCoordinate(schema, 'Query').kind; // => 'NamedType'
51
- * resolveSchemaCoordinate(schema, 'Query.reviews').kind; // => 'Field'
52
- * resolveSchemaCoordinate(schema, 'Query.reviews(input:)').kind; // => 'FieldArgument'
53
- * resolveSchemaCoordinate(schema, 'ReviewInput.stars').kind; // => 'InputField'
54
- * resolveSchemaCoordinate(schema, 'Episode.NEW_HOPE').kind; // => 'EnumValue'
55
- * resolveSchemaCoordinate(schema, '@tag').kind; // => 'Directive'
56
- * resolveSchemaCoordinate(schema, '@tag(name:)').kind; // => 'DirectiveArgument'
50
+ * resolveSchemaCoordinate(schema, 'Query')?.kind; // => 'NamedType'
51
+ * resolveSchemaCoordinate(schema, 'Query.reviews')?.kind; // => 'Field'
52
+ * resolveSchemaCoordinate(schema, 'Query.reviews(input:)')?.kind; // => 'FieldArgument'
53
+ * resolveSchemaCoordinate(schema, 'ReviewInput.stars')?.kind; // => 'InputField'
54
+ * resolveSchemaCoordinate(schema, 'Episode.NEW_HOPE')?.kind; // => 'EnumValue'
55
+ * resolveSchemaCoordinate(schema, '@tag')?.kind; // => 'Directive'
56
+ * resolveSchemaCoordinate(schema, '@tag(name:)')?.kind; // => 'DirectiveArgument'
57
57
  * resolveSchemaCoordinate(schema, 'Query.missing'); // => undefined
58
58
  * ```
59
59
  */
@@ -287,6 +287,7 @@ function resolveDirectiveArgumentCoordinate(schema, schemaCoordinate) {
287
287
  * @returns The schema element identified by the parsed coordinate, or undefined if none exists.
288
288
  * @example
289
289
  * ```ts
290
+ * import assert from 'node:assert/strict';
290
291
  * import { parseSchemaCoordinate } from 'graphql/language';
291
292
  * import { buildSchema, resolveASTSchemaCoordinate } from 'graphql/utilities';
292
293
  *
@@ -298,7 +299,7 @@ function resolveDirectiveArgumentCoordinate(schema, schemaCoordinate) {
298
299
  * const coordinate = parseSchemaCoordinate('Query.greeting(name:)');
299
300
  * const resolved = resolveASTSchemaCoordinate(schema, coordinate);
300
301
  *
301
- * resolved.kind; // => 'FieldArgument'
302
+ * assert(resolved?.kind === 'FieldArgument');
302
303
  * resolved.field.name; // => 'greeting'
303
304
  * resolved.fieldArgument.name; // => 'name'
304
305
  * ```
@@ -40,13 +40,13 @@ import {
40
40
  * }
41
41
  * `);
42
42
  *
43
- * resolveSchemaCoordinate(schema, 'Query').kind; // => 'NamedType'
44
- * resolveSchemaCoordinate(schema, 'Query.reviews').kind; // => 'Field'
45
- * resolveSchemaCoordinate(schema, 'Query.reviews(input:)').kind; // => 'FieldArgument'
46
- * resolveSchemaCoordinate(schema, 'ReviewInput.stars').kind; // => 'InputField'
47
- * resolveSchemaCoordinate(schema, 'Episode.NEW_HOPE').kind; // => 'EnumValue'
48
- * resolveSchemaCoordinate(schema, '@tag').kind; // => 'Directive'
49
- * resolveSchemaCoordinate(schema, '@tag(name:)').kind; // => 'DirectiveArgument'
43
+ * resolveSchemaCoordinate(schema, 'Query')?.kind; // => 'NamedType'
44
+ * resolveSchemaCoordinate(schema, 'Query.reviews')?.kind; // => 'Field'
45
+ * resolveSchemaCoordinate(schema, 'Query.reviews(input:)')?.kind; // => 'FieldArgument'
46
+ * resolveSchemaCoordinate(schema, 'ReviewInput.stars')?.kind; // => 'InputField'
47
+ * resolveSchemaCoordinate(schema, 'Episode.NEW_HOPE')?.kind; // => 'EnumValue'
48
+ * resolveSchemaCoordinate(schema, '@tag')?.kind; // => 'Directive'
49
+ * resolveSchemaCoordinate(schema, '@tag(name:)')?.kind; // => 'DirectiveArgument'
50
50
  * resolveSchemaCoordinate(schema, 'Query.missing'); // => undefined
51
51
  * ```
52
52
  */
@@ -269,6 +269,7 @@ function resolveDirectiveArgumentCoordinate(schema, schemaCoordinate) {
269
269
  * @returns The schema element identified by the parsed coordinate, or undefined if none exists.
270
270
  * @example
271
271
  * ```ts
272
+ * import assert from 'node:assert/strict';
272
273
  * import { parseSchemaCoordinate } from 'graphql/language';
273
274
  * import { buildSchema, resolveASTSchemaCoordinate } from 'graphql/utilities';
274
275
  *
@@ -280,7 +281,7 @@ function resolveDirectiveArgumentCoordinate(schema, schemaCoordinate) {
280
281
  * const coordinate = parseSchemaCoordinate('Query.greeting(name:)');
281
282
  * const resolved = resolveASTSchemaCoordinate(schema, coordinate);
282
283
  *
283
- * resolved.kind; // => 'FieldArgument'
284
+ * assert(resolved?.kind === 'FieldArgument');
284
285
  * resolved.field.name; // => 'greeting'
285
286
  * resolved.fieldArgument.name; // => 'name'
286
287
  * ```
@@ -32,8 +32,8 @@ import type { DocumentNode } from '../language/ast';
32
32
  * const separated = separateOperations(document);
33
33
  *
34
34
  * Object.keys(separated); // => ['GetUser', 'GetStatus']
35
- * print(separated.GetUser); // matches /fragment UserFields/
36
- * print(separated.GetStatus); // does not match /fragment UserFields/
35
+ * print(separated.GetUser).includes('fragment UserFields'); // => true
36
+ * print(separated.GetStatus).includes('fragment UserFields'); // => false
37
37
  * ```
38
38
  */
39
39
  export declare function separateOperations(
@@ -42,8 +42,8 @@ var _visitor = require('../language/visitor.js');
42
42
  * const separated = separateOperations(document);
43
43
  *
44
44
  * Object.keys(separated); // => ['GetUser', 'GetStatus']
45
- * print(separated.GetUser); // matches /fragment UserFields/
46
- * print(separated.GetStatus); // does not match /fragment UserFields/
45
+ * print(separated.GetUser).includes('fragment UserFields'); // => true
46
+ * print(separated.GetStatus).includes('fragment UserFields'); // => false
47
47
  * ```
48
48
  */
49
49
  function separateOperations(documentAST) {
@@ -32,8 +32,8 @@ import { visit } from '../language/visitor.mjs';
32
32
  * const separated = separateOperations(document);
33
33
  *
34
34
  * Object.keys(separated); // => ['GetUser', 'GetStatus']
35
- * print(separated.GetUser); // matches /fragment UserFields/
36
- * print(separated.GetStatus); // does not match /fragment UserFields/
35
+ * print(separated.GetUser).includes('fragment UserFields'); // => true
36
+ * print(separated.GetStatus).includes('fragment UserFields'); // => false
37
37
  * ```
38
38
  */
39
39
 
@@ -37,7 +37,15 @@ import { Source } from '../language/source';
37
37
  * Becomes:
38
38
  *
39
39
  * ```graphql
40
- * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}
40
+ * query SomeQuery($foo: String!, $bar: String) {
41
+ * someField(foo: $foo, bar: $bar) {
42
+ * a
43
+ * b {
44
+ * c
45
+ * d
46
+ * }
47
+ * }
48
+ * }
41
49
  * ```
42
50
  * @example SDL source
43
51
  * ```graphql
@@ -55,15 +63,21 @@ import { Source } from '../language/source';
55
63
  * Becomes:
56
64
  *
57
65
  * ```graphql
58
- * """Type description""" type Foo{"""Field description""" bar:String}
66
+ * """
67
+ * Type description
68
+ * """
69
+ * type Foo {
70
+ * """
71
+ * Field description
72
+ * """
73
+ * bar: String
74
+ * }
59
75
  * ```
60
76
  * @example
61
77
  * ```ts
62
78
  * import { stripIgnoredCharacters } from 'graphql/utilities';
63
79
  *
64
- * const source = stripIgnoredCharacters('query Example { name }');
65
- *
66
- * source; // => 'query Example{name}'
80
+ * const source = stripIgnoredCharacters('query Example { name }'); // => 'query Example{name}'
67
81
  * ```
68
82
  */
69
83
  export declare function stripIgnoredCharacters(source: string | Source): string;
@@ -52,7 +52,15 @@ var _tokenKind = require('../language/tokenKind.js');
52
52
  * Becomes:
53
53
  *
54
54
  * ```graphql
55
- * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}
55
+ * query SomeQuery($foo: String!, $bar: String) {
56
+ * someField(foo: $foo, bar: $bar) {
57
+ * a
58
+ * b {
59
+ * c
60
+ * d
61
+ * }
62
+ * }
63
+ * }
56
64
  * ```
57
65
  * @example SDL source
58
66
  * ```graphql
@@ -70,15 +78,21 @@ var _tokenKind = require('../language/tokenKind.js');
70
78
  * Becomes:
71
79
  *
72
80
  * ```graphql
73
- * """Type description""" type Foo{"""Field description""" bar:String}
81
+ * """
82
+ * Type description
83
+ * """
84
+ * type Foo {
85
+ * """
86
+ * Field description
87
+ * """
88
+ * bar: String
89
+ * }
74
90
  * ```
75
91
  * @example
76
92
  * ```ts
77
93
  * import { stripIgnoredCharacters } from 'graphql/utilities';
78
94
  *
79
- * const source = stripIgnoredCharacters('query Example { name }');
80
- *
81
- * source; // => 'query Example{name}'
95
+ * const source = stripIgnoredCharacters('query Example { name }'); // => 'query Example{name}'
82
96
  * ```
83
97
  */
84
98
  function stripIgnoredCharacters(source) {