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
@@ -122,7 +122,8 @@ class GraphQLDirective {
122
122
  * @param config - Configuration describing this object.
123
123
  * @example
124
124
  * ```ts
125
- * import { DirectiveLocation, parse } from 'graphql/language';
125
+ * import assert from 'node:assert/strict';
126
+ * import { DirectiveLocation, parse, Kind } from 'graphql/language';
126
127
  * import {
127
128
  * GraphQLBoolean,
128
129
  * GraphQLDirective,
@@ -130,10 +131,15 @@ class GraphQLDirective {
130
131
  * GraphQLNonNull,
131
132
  * } from 'graphql/type';
132
133
  *
133
- * const document = parse(`
134
+ * const document = parse(
135
+ * `
134
136
  * directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION
135
- * extend directive @cacheControl(maxAge: Int) on FIELD_DEFINITION
136
- * `);
137
+ * extend directive @cacheControl @tag
138
+ * `,
139
+ * { experimentalDirectivesOnDirectiveDefinitions: true },
140
+ * );
141
+ * assert(document.definitions[0].kind === Kind.DIRECTIVE_DEFINITION);
142
+ * assert(document.definitions[1].kind === Kind.DIRECTIVE_EXTENSION);
137
143
  * const definition = document.definitions[0];
138
144
  *
139
145
  * const cacheControl = new GraphQLDirective({
@@ -150,14 +156,14 @@ class GraphQLDirective {
150
156
  * },
151
157
  * maxAge: {
152
158
  * type: GraphQLInt,
153
- * astNode: definition.arguments[0],
159
+ * astNode: definition.arguments?.[0],
154
160
  * },
155
161
  * },
156
162
  * isRepeatable: true,
157
163
  * deprecationReason: 'Use @cache instead.',
158
164
  * extensions: { scope: 'cache' },
159
165
  * astNode: definition,
160
- * extensionASTNodes: [ document.definitions[1] ],
166
+ * extensionASTNodes: [document.definitions[1]],
161
167
  * });
162
168
  *
163
169
  * cacheControl.name; // => 'cacheControl'
@@ -99,7 +99,8 @@ export class GraphQLDirective {
99
99
  * @param config - Configuration describing this object.
100
100
  * @example
101
101
  * ```ts
102
- * import { DirectiveLocation, parse } from 'graphql/language';
102
+ * import assert from 'node:assert/strict';
103
+ * import { DirectiveLocation, parse, Kind } from 'graphql/language';
103
104
  * import {
104
105
  * GraphQLBoolean,
105
106
  * GraphQLDirective,
@@ -107,10 +108,15 @@ export class GraphQLDirective {
107
108
  * GraphQLNonNull,
108
109
  * } from 'graphql/type';
109
110
  *
110
- * const document = parse(`
111
+ * const document = parse(
112
+ * `
111
113
  * directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION
112
- * extend directive @cacheControl(maxAge: Int) on FIELD_DEFINITION
113
- * `);
114
+ * extend directive @cacheControl @tag
115
+ * `,
116
+ * { experimentalDirectivesOnDirectiveDefinitions: true },
117
+ * );
118
+ * assert(document.definitions[0].kind === Kind.DIRECTIVE_DEFINITION);
119
+ * assert(document.definitions[1].kind === Kind.DIRECTIVE_EXTENSION);
114
120
  * const definition = document.definitions[0];
115
121
  *
116
122
  * const cacheControl = new GraphQLDirective({
@@ -127,14 +133,14 @@ export class GraphQLDirective {
127
133
  * },
128
134
  * maxAge: {
129
135
  * type: GraphQLInt,
130
- * astNode: definition.arguments[0],
136
+ * astNode: definition.arguments?.[0],
131
137
  * },
132
138
  * },
133
139
  * isRepeatable: true,
134
140
  * deprecationReason: 'Use @cache instead.',
135
141
  * extensions: { scope: 'cache' },
136
142
  * astNode: definition,
137
- * extensionASTNodes: [ document.definitions[1] ],
143
+ * extensionASTNodes: [document.definitions[1]],
138
144
  * });
139
145
  *
140
146
  * cacheControl.name; // => 'cacheControl'
package/type/scalars.js CHANGED
@@ -100,7 +100,7 @@ const GraphQLInt = new _definition.GraphQLScalarType({
100
100
  parseLiteral(valueNode) {
101
101
  if (valueNode.kind !== _kinds.Kind.INT) {
102
102
  throw new _GraphQLError.GraphQLError(
103
- `Int cannot represent non-integer value: ${(0, _printer.print)(
103
+ `Int cannot represent non-integer value: ${(0, _printer.printForError)(
104
104
  valueNode,
105
105
  )}`,
106
106
  {
@@ -173,9 +173,8 @@ const GraphQLFloat = new _definition.GraphQLScalarType({
173
173
  valueNode.kind !== _kinds.Kind.INT
174
174
  ) {
175
175
  throw new _GraphQLError.GraphQLError(
176
- `Float cannot represent non numeric value: ${(0, _printer.print)(
177
- valueNode,
178
- )}`,
176
+ `Float cannot represent non numeric value: ${(0,
177
+ _printer.printForError)(valueNode)}`,
179
178
  valueNode,
180
179
  );
181
180
  }
@@ -227,9 +226,8 @@ const GraphQLString = new _definition.GraphQLScalarType({
227
226
  parseLiteral(valueNode) {
228
227
  if (valueNode.kind !== _kinds.Kind.STRING) {
229
228
  throw new _GraphQLError.GraphQLError(
230
- `String cannot represent a non string value: ${(0, _printer.print)(
231
- valueNode,
232
- )}`,
229
+ `String cannot represent a non string value: ${(0,
230
+ _printer.printForError)(valueNode)}`,
233
231
  {
234
232
  nodes: valueNode,
235
233
  },
@@ -279,9 +277,8 @@ const GraphQLBoolean = new _definition.GraphQLScalarType({
279
277
  parseLiteral(valueNode) {
280
278
  if (valueNode.kind !== _kinds.Kind.BOOLEAN) {
281
279
  throw new _GraphQLError.GraphQLError(
282
- `Boolean cannot represent a non boolean value: ${(0, _printer.print)(
283
- valueNode,
284
- )}`,
280
+ `Boolean cannot represent a non boolean value: ${(0,
281
+ _printer.printForError)(valueNode)}`,
285
282
  {
286
283
  nodes: valueNode,
287
284
  },
@@ -336,7 +333,7 @@ const GraphQLID = new _definition.GraphQLScalarType({
336
333
  ) {
337
334
  throw new _GraphQLError.GraphQLError(
338
335
  'ID cannot represent a non-string and non-integer value: ' +
339
- (0, _printer.print)(valueNode),
336
+ (0, _printer.printForError)(valueNode),
340
337
  {
341
338
  nodes: valueNode,
342
339
  },
package/type/scalars.mjs CHANGED
@@ -3,7 +3,7 @@ import { inspect } from '../jsutils/inspect.mjs';
3
3
  import { isObjectLike } from '../jsutils/isObjectLike.mjs';
4
4
  import { GraphQLError } from '../error/GraphQLError.mjs';
5
5
  import { Kind } from '../language/kinds.mjs';
6
- import { print } from '../language/printer.mjs';
6
+ import { printForError as print } from '../language/printer.mjs';
7
7
  import { GraphQLScalarType } from './definition.mjs';
8
8
  /**
9
9
  * Maximum possible Int value as per GraphQL Spec (32-bit signed integer).
package/type/schema.d.ts CHANGED
@@ -73,6 +73,8 @@ export interface GraphQLSchemaExtensions {
73
73
  * validator and executor.
74
74
  * @example
75
75
  * ```ts
76
+ * import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql';
77
+ *
76
78
  * const MyAppQueryRootType = new GraphQLObjectType({
77
79
  * name: 'Query',
78
80
  * fields: {
@@ -98,6 +100,13 @@ export interface GraphQLSchemaExtensions {
98
100
  * referenced.
99
101
  *
100
102
  * ```ts
103
+ * import {
104
+ * GraphQLInterfaceType,
105
+ * GraphQLObjectType,
106
+ * GraphQLSchema,
107
+ * GraphQLString,
108
+ * } from 'graphql';
109
+ *
101
110
  * const characterInterface = new GraphQLInterfaceType({
102
111
  * name: 'Character',
103
112
  * fields: {
@@ -142,9 +151,26 @@ export interface GraphQLSchemaExtensions {
142
151
  * these specified directives, you must explicitly declare them.
143
152
  *
144
153
  * ```ts
154
+ * import {
155
+ * DirectiveLocation,
156
+ * GraphQLDirective,
157
+ * GraphQLObjectType,
158
+ * GraphQLSchema,
159
+ * GraphQLString,
160
+ * specifiedDirectives,
161
+ * } from 'graphql';
162
+ *
145
163
  * const MyAppSchema = new GraphQLSchema({
146
- * query: MyAppQueryRootType,
147
- * directives: specifiedDirectives.concat([myCustomDirective]),
164
+ * query: new GraphQLObjectType({
165
+ * name: 'Query',
166
+ * fields: { greeting: { type: GraphQLString } },
167
+ * }),
168
+ * directives: specifiedDirectives.concat([
169
+ * new GraphQLDirective({
170
+ * name: 'custom',
171
+ * locations: [DirectiveLocation.FIELD],
172
+ * }),
173
+ * ]),
148
174
  * });
149
175
  * ```
150
176
  */
@@ -175,11 +201,7 @@ export declare class GraphQLSchema {
175
201
  * @example
176
202
  * ```ts
177
203
  * // Create a schema with the required query root.
178
- * import {
179
- * GraphQLObjectType,
180
- * GraphQLSchema,
181
- * GraphQLString,
182
- * } from 'graphql/type';
204
+ * import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql/type';
183
205
  *
184
206
  * const Query = new GraphQLObjectType({
185
207
  * name: 'Query',
@@ -201,8 +223,9 @@ export declare class GraphQLSchema {
201
223
  * ```
202
224
  * @example
203
225
  * ```ts
226
+ * import assert from 'node:assert/strict';
204
227
  * // This variant configures every schema option, including directives and extensions.
205
- * import { DirectiveLocation, parse } from 'graphql/language';
228
+ * import { DirectiveLocation, parse, Kind } from 'graphql/language';
206
229
  * import {
207
230
  * GraphQLBoolean,
208
231
  * GraphQLDirective,
@@ -241,6 +264,8 @@ export declare class GraphQLSchema {
241
264
  *
242
265
  * extend schema @auth
243
266
  * `);
267
+ * assert(schemaDocument.definitions[0].kind === Kind.SCHEMA_DEFINITION);
268
+ * assert(schemaDocument.definitions[1].kind === Kind.SCHEMA_EXTENSION);
244
269
  *
245
270
  * const schema = new GraphQLSchema({
246
271
  * description: 'Operations exposed by the application.',
@@ -251,7 +276,7 @@ export declare class GraphQLSchema {
251
276
  * directives: [authDirective],
252
277
  * extensions: { owner: 'platform' },
253
278
  * astNode: schemaDocument.definitions[0],
254
- * extensionASTNodes: [ schemaDocument.definitions[1] ],
279
+ * extensionASTNodes: [schemaDocument.definitions[1]],
255
280
  * assumeValid: true,
256
281
  * });
257
282
  *
@@ -536,7 +561,7 @@ export declare class GraphQLSchema {
536
561
  * }
537
562
  * `);
538
563
  *
539
- * schema.getDirectives().map((directive) => directive.name); // => ['include', 'skip', 'deprecated', 'specifiedBy', 'oneOf', 'upper']
564
+ * schema.getDirectives().map((directive) => directive.name); // => ['upper', 'include', 'skip', 'deprecated', 'specifiedBy', 'oneOf']
540
565
  * ```
541
566
  */
542
567
  getDirectives(): ReadonlyArray<GraphQLDirective>;
@@ -609,7 +634,7 @@ export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
609
634
  mutation?: Maybe<GraphQLObjectType>;
610
635
  /** Root object type for subscription operations. */
611
636
  subscription?: Maybe<GraphQLObjectType>;
612
- /** Object types that belong to this union type. */
637
+ /** Additional named types to include in the schema. */
613
638
  types?: Maybe<ReadonlyArray<GraphQLNamedType>>;
614
639
  /** Directives available in this schema or applied to this AST node. */
615
640
  directives?: Maybe<ReadonlyArray<GraphQLDirective>>;
package/type/schema.js CHANGED
@@ -95,6 +95,8 @@ function assertSchema(schema) {
95
95
  * validator and executor.
96
96
  * @example
97
97
  * ```ts
98
+ * import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql';
99
+ *
98
100
  * const MyAppQueryRootType = new GraphQLObjectType({
99
101
  * name: 'Query',
100
102
  * fields: {
@@ -120,6 +122,13 @@ function assertSchema(schema) {
120
122
  * referenced.
121
123
  *
122
124
  * ```ts
125
+ * import {
126
+ * GraphQLInterfaceType,
127
+ * GraphQLObjectType,
128
+ * GraphQLSchema,
129
+ * GraphQLString,
130
+ * } from 'graphql';
131
+ *
123
132
  * const characterInterface = new GraphQLInterfaceType({
124
133
  * name: 'Character',
125
134
  * fields: {
@@ -164,9 +173,26 @@ function assertSchema(schema) {
164
173
  * these specified directives, you must explicitly declare them.
165
174
  *
166
175
  * ```ts
176
+ * import {
177
+ * DirectiveLocation,
178
+ * GraphQLDirective,
179
+ * GraphQLObjectType,
180
+ * GraphQLSchema,
181
+ * GraphQLString,
182
+ * specifiedDirectives,
183
+ * } from 'graphql';
184
+ *
167
185
  * const MyAppSchema = new GraphQLSchema({
168
- * query: MyAppQueryRootType,
169
- * directives: specifiedDirectives.concat([myCustomDirective]),
186
+ * query: new GraphQLObjectType({
187
+ * name: 'Query',
188
+ * fields: { greeting: { type: GraphQLString } },
189
+ * }),
190
+ * directives: specifiedDirectives.concat([
191
+ * new GraphQLDirective({
192
+ * name: 'custom',
193
+ * locations: [DirectiveLocation.FIELD],
194
+ * }),
195
+ * ]),
170
196
  * });
171
197
  * ```
172
198
  */
@@ -190,11 +216,7 @@ class GraphQLSchema {
190
216
  * @example
191
217
  * ```ts
192
218
  * // Create a schema with the required query root.
193
- * import {
194
- * GraphQLObjectType,
195
- * GraphQLSchema,
196
- * GraphQLString,
197
- * } from 'graphql/type';
219
+ * import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql/type';
198
220
  *
199
221
  * const Query = new GraphQLObjectType({
200
222
  * name: 'Query',
@@ -216,8 +238,9 @@ class GraphQLSchema {
216
238
  * ```
217
239
  * @example
218
240
  * ```ts
241
+ * import assert from 'node:assert/strict';
219
242
  * // This variant configures every schema option, including directives and extensions.
220
- * import { DirectiveLocation, parse } from 'graphql/language';
243
+ * import { DirectiveLocation, parse, Kind } from 'graphql/language';
221
244
  * import {
222
245
  * GraphQLBoolean,
223
246
  * GraphQLDirective,
@@ -256,6 +279,8 @@ class GraphQLSchema {
256
279
  *
257
280
  * extend schema @auth
258
281
  * `);
282
+ * assert(schemaDocument.definitions[0].kind === Kind.SCHEMA_DEFINITION);
283
+ * assert(schemaDocument.definitions[1].kind === Kind.SCHEMA_EXTENSION);
259
284
  *
260
285
  * const schema = new GraphQLSchema({
261
286
  * description: 'Operations exposed by the application.',
@@ -266,7 +291,7 @@ class GraphQLSchema {
266
291
  * directives: [authDirective],
267
292
  * extensions: { owner: 'platform' },
268
293
  * astNode: schemaDocument.definitions[0],
269
- * extensionASTNodes: [ schemaDocument.definitions[1] ],
294
+ * extensionASTNodes: [schemaDocument.definitions[1]],
270
295
  * assumeValid: true,
271
296
  * });
272
297
  *
@@ -750,7 +775,7 @@ class GraphQLSchema {
750
775
  * }
751
776
  * `);
752
777
  *
753
- * schema.getDirectives().map((directive) => directive.name); // => ['include', 'skip', 'deprecated', 'specifiedBy', 'oneOf', 'upper']
778
+ * schema.getDirectives().map((directive) => directive.name); // => ['upper', 'include', 'skip', 'deprecated', 'specifiedBy', 'oneOf']
754
779
  * ```
755
780
  */
756
781
 
package/type/schema.mjs CHANGED
@@ -81,6 +81,8 @@ export function assertSchema(schema) {
81
81
  * validator and executor.
82
82
  * @example
83
83
  * ```ts
84
+ * import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql';
85
+ *
84
86
  * const MyAppQueryRootType = new GraphQLObjectType({
85
87
  * name: 'Query',
86
88
  * fields: {
@@ -106,6 +108,13 @@ export function assertSchema(schema) {
106
108
  * referenced.
107
109
  *
108
110
  * ```ts
111
+ * import {
112
+ * GraphQLInterfaceType,
113
+ * GraphQLObjectType,
114
+ * GraphQLSchema,
115
+ * GraphQLString,
116
+ * } from 'graphql';
117
+ *
109
118
  * const characterInterface = new GraphQLInterfaceType({
110
119
  * name: 'Character',
111
120
  * fields: {
@@ -150,9 +159,26 @@ export function assertSchema(schema) {
150
159
  * these specified directives, you must explicitly declare them.
151
160
  *
152
161
  * ```ts
162
+ * import {
163
+ * DirectiveLocation,
164
+ * GraphQLDirective,
165
+ * GraphQLObjectType,
166
+ * GraphQLSchema,
167
+ * GraphQLString,
168
+ * specifiedDirectives,
169
+ * } from 'graphql';
170
+ *
153
171
  * const MyAppSchema = new GraphQLSchema({
154
- * query: MyAppQueryRootType,
155
- * directives: specifiedDirectives.concat([myCustomDirective]),
172
+ * query: new GraphQLObjectType({
173
+ * name: 'Query',
174
+ * fields: { greeting: { type: GraphQLString } },
175
+ * }),
176
+ * directives: specifiedDirectives.concat([
177
+ * new GraphQLDirective({
178
+ * name: 'custom',
179
+ * locations: [DirectiveLocation.FIELD],
180
+ * }),
181
+ * ]),
156
182
  * });
157
183
  * ```
158
184
  */
@@ -176,11 +202,7 @@ export class GraphQLSchema {
176
202
  * @example
177
203
  * ```ts
178
204
  * // Create a schema with the required query root.
179
- * import {
180
- * GraphQLObjectType,
181
- * GraphQLSchema,
182
- * GraphQLString,
183
- * } from 'graphql/type';
205
+ * import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql/type';
184
206
  *
185
207
  * const Query = new GraphQLObjectType({
186
208
  * name: 'Query',
@@ -202,8 +224,9 @@ export class GraphQLSchema {
202
224
  * ```
203
225
  * @example
204
226
  * ```ts
227
+ * import assert from 'node:assert/strict';
205
228
  * // This variant configures every schema option, including directives and extensions.
206
- * import { DirectiveLocation, parse } from 'graphql/language';
229
+ * import { DirectiveLocation, parse, Kind } from 'graphql/language';
207
230
  * import {
208
231
  * GraphQLBoolean,
209
232
  * GraphQLDirective,
@@ -242,6 +265,8 @@ export class GraphQLSchema {
242
265
  *
243
266
  * extend schema @auth
244
267
  * `);
268
+ * assert(schemaDocument.definitions[0].kind === Kind.SCHEMA_DEFINITION);
269
+ * assert(schemaDocument.definitions[1].kind === Kind.SCHEMA_EXTENSION);
245
270
  *
246
271
  * const schema = new GraphQLSchema({
247
272
  * description: 'Operations exposed by the application.',
@@ -252,7 +277,7 @@ export class GraphQLSchema {
252
277
  * directives: [authDirective],
253
278
  * extensions: { owner: 'platform' },
254
279
  * astNode: schemaDocument.definitions[0],
255
- * extensionASTNodes: [ schemaDocument.definitions[1] ],
280
+ * extensionASTNodes: [schemaDocument.definitions[1]],
256
281
  * assumeValid: true,
257
282
  * });
258
283
  *
@@ -734,7 +759,7 @@ export class GraphQLSchema {
734
759
  * }
735
760
  * `);
736
761
  *
737
- * schema.getDirectives().map((directive) => directive.name); // => ['include', 'skip', 'deprecated', 'specifiedBy', 'oneOf', 'upper']
762
+ * schema.getDirectives().map((directive) => directive.name); // => ['upper', 'include', 'skip', 'deprecated', 'specifiedBy', 'oneOf']
738
763
  * ```
739
764
  */
740
765
 
@@ -19,9 +19,7 @@ import type { GraphQLSchema } from './schema';
19
19
  * name: String
20
20
  * }
21
21
  * `);
22
- * const errors = validateSchema(schema);
23
- *
24
- * errors; // => []
22
+ * const errors = validateSchema(schema); // => []
25
23
  * ```
26
24
  */
27
25
  export declare function validateSchema(
package/type/validate.js CHANGED
@@ -42,9 +42,7 @@ var _schema = require('./schema.js');
42
42
  * name: String
43
43
  * }
44
44
  * `);
45
- * const errors = validateSchema(schema);
46
- *
47
- * errors; // => []
45
+ * const errors = validateSchema(schema); // => []
48
46
  * ```
49
47
  */
50
48
  function validateSchema(schema) {
package/type/validate.mjs CHANGED
@@ -37,9 +37,7 @@ import { assertSchema } from './schema.mjs';
37
37
  * name: String
38
38
  * }
39
39
  * `);
40
- * const errors = validateSchema(schema);
41
- *
42
- * errors; // => []
40
+ * const errors = validateSchema(schema); // => []
43
41
  * ```
44
42
  */
45
43
 
@@ -47,7 +47,7 @@ export declare class TypeInfo {
47
47
  * }
48
48
  * `);
49
49
  * const typeInfo = new TypeInfo(schema);
50
- * const seenTypes = [];
50
+ * const seenTypes: Array<string> = [];
51
51
  *
52
52
  * visit(
53
53
  * parse('{ greeting }'),
@@ -134,7 +134,7 @@ export declare class TypeInfo {
134
134
  * }
135
135
  * `);
136
136
  * const typeInfo = new TypeInfo(schema);
137
- * const fieldTypes = {};
137
+ * const fieldTypes: Record<string, string> = {};
138
138
  *
139
139
  * visit(
140
140
  * parse('{ viewer { name } }'),
@@ -167,7 +167,7 @@ export declare class TypeInfo {
167
167
  * }
168
168
  * `);
169
169
  * const typeInfo = new TypeInfo(schema);
170
- * const parentTypes = {};
170
+ * const parentTypes: Record<string, string> = {};
171
171
  *
172
172
  * visit(
173
173
  * parse('{ viewer { name } }'),
@@ -201,7 +201,7 @@ export declare class TypeInfo {
201
201
  * }
202
202
  * `);
203
203
  * const typeInfo = new TypeInfo(schema);
204
- * const inputTypes = {};
204
+ * const inputTypes: Record<string, string> = {};
205
205
  *
206
206
  * visit(
207
207
  * parse('{ reviews(stars: 5, sort: OLDEST) }'),
@@ -234,7 +234,7 @@ export declare class TypeInfo {
234
234
  * }
235
235
  * `);
236
236
  * const typeInfo = new TypeInfo(schema);
237
- * const parentInputTypes = {};
237
+ * const parentInputTypes: Record<string, string> = {};
238
238
  *
239
239
  * visit(
240
240
  * parse('{ reviews(filter: { stars: 5 }) }'),
@@ -292,7 +292,7 @@ export declare class TypeInfo {
292
292
  * }
293
293
  * `);
294
294
  * const typeInfo = new TypeInfo(schema);
295
- * let defaultLimit;
295
+ * let defaultLimit: unknown;
296
296
  *
297
297
  * visit(
298
298
  * parse('{ reviews(limit: 5) }'),
@@ -405,6 +405,7 @@ export declare class TypeInfo {
405
405
  * @returns Nothing.
406
406
  * @example
407
407
  * ```ts
408
+ * import assert from 'node:assert/strict';
408
409
  * import { Kind, parse } from 'graphql/language';
409
410
  * import { buildSchema, TypeInfo } from 'graphql/utilities';
410
411
  *
@@ -415,6 +416,7 @@ export declare class TypeInfo {
415
416
  * `);
416
417
  * const document = parse('{ greeting }');
417
418
  * const operation = document.definitions[0];
419
+ * assert(operation.kind === Kind.OPERATION_DEFINITION);
418
420
  * const selectionSet = operation.selectionSet;
419
421
  * const field = selectionSet.selections[0];
420
422
  * const typeInfo = new TypeInfo(schema);
@@ -430,12 +432,13 @@ export declare class TypeInfo {
430
432
  */
431
433
  enter(node: ASTNode): void;
432
434
  /**
433
- * Updates this TypeInfo instance for a left AST node.
434
- * @param node - AST node being entered.
435
+ * Updates this TypeInfo instance when leaving an AST node.
436
+ * @param node - AST node being left.
435
437
  * @returns Nothing.
436
438
  * @example
437
439
  * ```ts
438
- * import { parse } from 'graphql/language';
440
+ * import assert from 'node:assert/strict';
441
+ * import { parse, Kind } from 'graphql/language';
439
442
  * import { buildSchema, TypeInfo } from 'graphql/utilities';
440
443
  *
441
444
  * const schema = buildSchema(`
@@ -445,6 +448,7 @@ export declare class TypeInfo {
445
448
  * `);
446
449
  * const document = parse('{ greeting }');
447
450
  * const operation = document.definitions[0];
451
+ * assert(operation.kind === Kind.OPERATION_DEFINITION);
448
452
  * const selectionSet = operation.selectionSet;
449
453
  * const field = selectionSet.selections[0];
450
454
  * const typeInfo = new TypeInfo(schema);
@@ -455,7 +459,7 @@ export declare class TypeInfo {
455
459
  * String(typeInfo.getType()); // => 'String'
456
460
  *
457
461
  * typeInfo.leave(field);
458
- * typeInfo.getType(); // => undefined
462
+ * String(typeInfo.getType()); // => 'Query'
459
463
  * ```
460
464
  */
461
465
  leave(node: ASTNode): void;
@@ -482,7 +486,7 @@ declare type GetFieldDefFn = (
482
486
  * }
483
487
  * `);
484
488
  * const typeInfo = new TypeInfo(schema);
485
- * const fields = [];
489
+ * const fields: Array<{ name: string; parentType: string; type: string }> = [];
486
490
  *
487
491
  * visit(
488
492
  * parse('{ greeting }'),