graphql 16.14.0 → 16.14.1

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 (371) hide show
  1. package/error/GraphQLError.d.ts +151 -15
  2. package/error/GraphQLError.js +143 -12
  3. package/error/GraphQLError.mjs +143 -12
  4. package/error/index.d.ts +6 -0
  5. package/error/index.mjs +6 -0
  6. package/error/locatedError.d.ts +20 -0
  7. package/error/locatedError.js +21 -0
  8. package/error/locatedError.mjs +20 -0
  9. package/error/syntaxError.d.ts +15 -0
  10. package/error/syntaxError.js +16 -0
  11. package/error/syntaxError.mjs +15 -0
  12. package/execution/collectFields.js +6 -0
  13. package/execution/collectFields.mjs +6 -0
  14. package/execution/execute.d.ts +211 -12
  15. package/execution/execute.js +214 -23
  16. package/execution/execute.mjs +213 -23
  17. package/execution/index.d.ts +6 -0
  18. package/execution/index.mjs +6 -0
  19. package/execution/mapAsyncIterator.d.ts +2 -0
  20. package/execution/mapAsyncIterator.js +2 -0
  21. package/execution/mapAsyncIterator.mjs +2 -0
  22. package/execution/subscribe.d.ts +195 -5
  23. package/execution/subscribe.js +154 -11
  24. package/execution/subscribe.mjs +153 -11
  25. package/execution/values.d.ts +167 -10
  26. package/execution/values.js +149 -5
  27. package/execution/values.mjs +148 -5
  28. package/graphql.d.ts +163 -41
  29. package/graphql.js +126 -4
  30. package/graphql.mjs +131 -41
  31. package/index.d.ts +11 -17
  32. package/index.mjs +13 -19
  33. package/jsutils/Maybe.d.ts +5 -1
  34. package/jsutils/ObjMap.d.ts +4 -0
  35. package/jsutils/Path.d.ts +30 -0
  36. package/jsutils/Path.js +29 -0
  37. package/jsutils/Path.mjs +29 -0
  38. package/jsutils/PromiseOrValue.d.ts +1 -0
  39. package/jsutils/devAssert.d.ts +1 -0
  40. package/jsutils/devAssert.js +1 -0
  41. package/jsutils/devAssert.mjs +1 -0
  42. package/jsutils/didYouMean.d.ts +4 -1
  43. package/jsutils/didYouMean.js +4 -1
  44. package/jsutils/didYouMean.mjs +4 -1
  45. package/jsutils/groupBy.d.ts +2 -0
  46. package/jsutils/groupBy.js +2 -0
  47. package/jsutils/groupBy.mjs +2 -0
  48. package/jsutils/identityFunc.d.ts +2 -0
  49. package/jsutils/identityFunc.js +2 -0
  50. package/jsutils/identityFunc.mjs +2 -0
  51. package/jsutils/inspect.d.ts +2 -0
  52. package/jsutils/inspect.js +2 -0
  53. package/jsutils/inspect.mjs +2 -0
  54. package/jsutils/instanceOf.d.ts +2 -0
  55. package/jsutils/instanceOf.js +2 -0
  56. package/jsutils/instanceOf.mjs +2 -0
  57. package/jsutils/invariant.d.ts +1 -0
  58. package/jsutils/invariant.js +1 -0
  59. package/jsutils/invariant.mjs +1 -0
  60. package/jsutils/isAsyncIterable.d.ts +2 -0
  61. package/jsutils/isAsyncIterable.js +2 -0
  62. package/jsutils/isAsyncIterable.mjs +2 -0
  63. package/jsutils/isIterableObject.d.ts +6 -5
  64. package/jsutils/isIterableObject.js +6 -5
  65. package/jsutils/isIterableObject.mjs +6 -5
  66. package/jsutils/isObjectLike.d.ts +2 -0
  67. package/jsutils/isObjectLike.js +2 -0
  68. package/jsutils/isObjectLike.mjs +2 -0
  69. package/jsutils/isPromise.d.ts +2 -0
  70. package/jsutils/isPromise.js +2 -0
  71. package/jsutils/isPromise.mjs +2 -0
  72. package/jsutils/keyMap.d.ts +7 -14
  73. package/jsutils/keyMap.js +7 -14
  74. package/jsutils/keyMap.mjs +7 -14
  75. package/jsutils/keyValMap.d.ts +9 -6
  76. package/jsutils/keyValMap.js +9 -6
  77. package/jsutils/keyValMap.mjs +9 -6
  78. package/jsutils/mapValue.d.ts +2 -0
  79. package/jsutils/mapValue.js +2 -0
  80. package/jsutils/mapValue.mjs +2 -0
  81. package/jsutils/memoize3.d.ts +2 -0
  82. package/jsutils/memoize3.js +2 -0
  83. package/jsutils/memoize3.mjs +2 -0
  84. package/jsutils/naturalCompare.d.ts +2 -0
  85. package/jsutils/naturalCompare.js +2 -0
  86. package/jsutils/naturalCompare.mjs +2 -0
  87. package/jsutils/printPathArray.d.ts +2 -0
  88. package/jsutils/printPathArray.js +2 -0
  89. package/jsutils/printPathArray.mjs +2 -0
  90. package/jsutils/promiseForObject.d.ts +2 -0
  91. package/jsutils/promiseForObject.js +2 -0
  92. package/jsutils/promiseForObject.mjs +2 -0
  93. package/jsutils/promiseReduce.d.ts +2 -0
  94. package/jsutils/promiseReduce.js +2 -0
  95. package/jsutils/promiseReduce.mjs +2 -0
  96. package/jsutils/suggestionList.d.ts +2 -0
  97. package/jsutils/suggestionList.js +4 -0
  98. package/jsutils/suggestionList.mjs +4 -0
  99. package/jsutils/toError.d.ts +2 -0
  100. package/jsutils/toError.js +2 -0
  101. package/jsutils/toError.mjs +2 -0
  102. package/jsutils/toObjMap.d.ts +1 -0
  103. package/jsutils/toObjMap.js +1 -0
  104. package/jsutils/toObjMap.mjs +1 -0
  105. package/language/ast.d.ts +412 -54
  106. package/language/ast.js +95 -38
  107. package/language/ast.mjs +95 -38
  108. package/language/blockString.d.ts +1 -3
  109. package/language/blockString.js +1 -3
  110. package/language/blockString.mjs +1 -3
  111. package/language/directiveLocation.d.ts +28 -8
  112. package/language/directiveLocation.js +9 -6
  113. package/language/directiveLocation.mjs +9 -6
  114. package/language/index.d.ts +6 -0
  115. package/language/index.mjs +6 -0
  116. package/language/kinds.d.ts +57 -18
  117. package/language/kinds.js +9 -6
  118. package/language/kinds.mjs +9 -6
  119. package/language/lexer.d.ts +47 -14
  120. package/language/lexer.js +71 -13
  121. package/language/lexer.mjs +70 -13
  122. package/language/location.d.ts +16 -3
  123. package/language/location.js +14 -3
  124. package/language/location.mjs +14 -3
  125. package/language/parser.d.ts +236 -13
  126. package/language/parser.js +224 -0
  127. package/language/parser.mjs +224 -3
  128. package/language/predicates.d.ts +169 -0
  129. package/language/predicates.js +170 -0
  130. package/language/predicates.mjs +180 -0
  131. package/language/printLocation.d.ts +28 -0
  132. package/language/printLocation.js +29 -0
  133. package/language/printLocation.mjs +28 -0
  134. package/language/printString.d.ts +2 -0
  135. package/language/printString.js +5 -1
  136. package/language/printString.mjs +5 -1
  137. package/language/printer.d.ts +12 -0
  138. package/language/printer.js +19 -0
  139. package/language/printer.mjs +18 -0
  140. package/language/schemaCoordinateLexer.d.ts +8 -6
  141. package/language/schemaCoordinateLexer.js +10 -6
  142. package/language/schemaCoordinateLexer.mjs +10 -6
  143. package/language/source.d.ts +28 -0
  144. package/language/source.js +32 -0
  145. package/language/source.mjs +31 -0
  146. package/language/tokenKind.d.ts +30 -3
  147. package/language/tokenKind.js +8 -3
  148. package/language/tokenKind.mjs +8 -3
  149. package/language/visitor.d.ts +200 -72
  150. package/language/visitor.js +122 -50
  151. package/language/visitor.mjs +122 -54
  152. package/package.json +1 -1
  153. package/subscription/index.d.ts +9 -3
  154. package/subscription/index.mjs +9 -3
  155. package/type/assertName.d.ts +18 -1
  156. package/type/assertName.js +19 -1
  157. package/type/assertName.mjs +18 -1
  158. package/type/definition.d.ts +2540 -79
  159. package/type/definition.js +2214 -61
  160. package/type/definition.mjs +2241 -60
  161. package/type/directives.d.ts +193 -18
  162. package/type/directives.js +196 -19
  163. package/type/directives.mjs +196 -19
  164. package/type/index.d.ts +6 -0
  165. package/type/index.mjs +6 -0
  166. package/type/introspection.d.ts +36 -0
  167. package/type/introspection.js +33 -0
  168. package/type/introspection.mjs +41 -0
  169. package/type/scalars.d.ts +29 -2
  170. package/type/scalars.js +37 -2
  171. package/type/scalars.mjs +36 -2
  172. package/type/schema.d.ts +490 -28
  173. package/type/schema.js +484 -26
  174. package/type/schema.mjs +484 -26
  175. package/type/validate.d.ts +31 -0
  176. package/type/validate.js +32 -0
  177. package/type/validate.mjs +31 -0
  178. package/utilities/TypeInfo.d.ts +441 -1
  179. package/utilities/TypeInfo.js +444 -1
  180. package/utilities/TypeInfo.mjs +443 -1
  181. package/utilities/assertValidName.d.ts +27 -2
  182. package/utilities/assertValidName.js +28 -2
  183. package/utilities/assertValidName.mjs +27 -2
  184. package/utilities/astFromValue.d.ts +33 -3
  185. package/utilities/astFromValue.js +36 -3
  186. package/utilities/astFromValue.mjs +35 -3
  187. package/utilities/buildASTSchema.d.ts +65 -6
  188. package/utilities/buildASTSchema.js +65 -6
  189. package/utilities/buildASTSchema.mjs +65 -6
  190. package/utilities/buildClientSchema.d.ts +15 -0
  191. package/utilities/buildClientSchema.js +16 -0
  192. package/utilities/buildClientSchema.mjs +15 -0
  193. package/utilities/coerceInputValue.d.ts +46 -0
  194. package/utilities/coerceInputValue.js +47 -0
  195. package/utilities/coerceInputValue.mjs +46 -0
  196. package/utilities/concatAST.d.ts +12 -0
  197. package/utilities/concatAST.js +13 -0
  198. package/utilities/concatAST.mjs +12 -0
  199. package/utilities/extendSchema.d.ts +56 -3
  200. package/utilities/extendSchema.js +63 -3
  201. package/utilities/extendSchema.mjs +62 -3
  202. package/utilities/findBreakingChanges.d.ts +95 -0
  203. package/utilities/findBreakingChanges.js +68 -0
  204. package/utilities/findBreakingChanges.mjs +70 -0
  205. package/utilities/getIntrospectionQuery.d.ts +132 -0
  206. package/utilities/getIntrospectionQuery.js +41 -0
  207. package/utilities/getIntrospectionQuery.mjs +41 -0
  208. package/utilities/getOperationAST.d.ts +15 -0
  209. package/utilities/getOperationAST.js +16 -0
  210. package/utilities/getOperationAST.mjs +15 -0
  211. package/utilities/getOperationRootType.d.ts +18 -1
  212. package/utilities/getOperationRootType.js +19 -1
  213. package/utilities/getOperationRootType.mjs +18 -1
  214. package/utilities/index.d.ts +7 -0
  215. package/utilities/index.mjs +7 -0
  216. package/utilities/introspectionFromSchema.d.ts +54 -0
  217. package/utilities/introspectionFromSchema.js +55 -0
  218. package/utilities/introspectionFromSchema.mjs +54 -0
  219. package/utilities/lexicographicSortSchema.d.ts +35 -0
  220. package/utilities/lexicographicSortSchema.js +36 -0
  221. package/utilities/lexicographicSortSchema.mjs +35 -0
  222. package/utilities/printSchema.d.ts +63 -0
  223. package/utilities/printSchema.js +66 -0
  224. package/utilities/printSchema.mjs +67 -0
  225. package/utilities/resolveSchemaCoordinate.d.ts +62 -0
  226. package/utilities/resolveSchemaCoordinate.js +64 -0
  227. package/utilities/resolveSchemaCoordinate.mjs +63 -0
  228. package/utilities/separateOperations.d.ts +30 -0
  229. package/utilities/separateOperations.js +31 -0
  230. package/utilities/separateOperations.mjs +30 -0
  231. package/utilities/stripIgnoredCharacters.d.ts +13 -6
  232. package/utilities/stripIgnoredCharacters.js +16 -6
  233. package/utilities/stripIgnoredCharacters.mjs +15 -6
  234. package/utilities/typeComparators.d.ts +84 -0
  235. package/utilities/typeComparators.js +85 -0
  236. package/utilities/typeComparators.mjs +84 -0
  237. package/utilities/typeFromAST.d.ts +86 -0
  238. package/utilities/typeFromAST.js +3 -0
  239. package/utilities/typeFromAST.mjs +3 -0
  240. package/utilities/typedQueryDocumentNode.d.ts +4 -0
  241. package/utilities/valueFromAST.d.ts +38 -0
  242. package/utilities/valueFromAST.js +39 -0
  243. package/utilities/valueFromAST.mjs +38 -0
  244. package/utilities/valueFromASTUntyped.d.ts +15 -2
  245. package/utilities/valueFromASTUntyped.js +16 -2
  246. package/utilities/valueFromASTUntyped.mjs +15 -2
  247. package/validation/ValidationContext.d.ts +399 -0
  248. package/validation/ValidationContext.js +400 -0
  249. package/validation/ValidationContext.mjs +401 -0
  250. package/validation/index.d.ts +6 -0
  251. package/validation/index.mjs +6 -0
  252. package/validation/rules/ExecutableDefinitionsRule.d.ts +28 -0
  253. package/validation/rules/ExecutableDefinitionsRule.js +29 -0
  254. package/validation/rules/ExecutableDefinitionsRule.mjs +28 -0
  255. package/validation/rules/FieldsOnCorrectTypeRule.d.ts +28 -0
  256. package/validation/rules/FieldsOnCorrectTypeRule.js +33 -0
  257. package/validation/rules/FieldsOnCorrectTypeRule.mjs +32 -0
  258. package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +28 -0
  259. package/validation/rules/FragmentsOnCompositeTypesRule.js +29 -0
  260. package/validation/rules/FragmentsOnCompositeTypesRule.mjs +28 -0
  261. package/validation/rules/KnownArgumentNamesRule.d.ts +29 -3
  262. package/validation/rules/KnownArgumentNamesRule.js +30 -3
  263. package/validation/rules/KnownArgumentNamesRule.mjs +29 -3
  264. package/validation/rules/KnownDirectivesRule.d.ts +28 -0
  265. package/validation/rules/KnownDirectivesRule.js +29 -0
  266. package/validation/rules/KnownDirectivesRule.mjs +28 -0
  267. package/validation/rules/KnownFragmentNamesRule.d.ts +28 -0
  268. package/validation/rules/KnownFragmentNamesRule.js +29 -0
  269. package/validation/rules/KnownFragmentNamesRule.mjs +28 -0
  270. package/validation/rules/KnownTypeNamesRule.d.ts +28 -0
  271. package/validation/rules/KnownTypeNamesRule.js +29 -0
  272. package/validation/rules/KnownTypeNamesRule.mjs +28 -0
  273. package/validation/rules/LoneAnonymousOperationRule.d.ts +28 -0
  274. package/validation/rules/LoneAnonymousOperationRule.js +29 -0
  275. package/validation/rules/LoneAnonymousOperationRule.mjs +28 -0
  276. package/validation/rules/LoneSchemaDefinitionRule.d.ts +21 -0
  277. package/validation/rules/LoneSchemaDefinitionRule.js +22 -0
  278. package/validation/rules/LoneSchemaDefinitionRule.mjs +21 -0
  279. package/validation/rules/MaxIntrospectionDepthRule.d.ts +31 -0
  280. package/validation/rules/MaxIntrospectionDepthRule.js +33 -0
  281. package/validation/rules/MaxIntrospectionDepthRule.mjs +34 -0
  282. package/validation/rules/NoFragmentCyclesRule.d.ts +28 -0
  283. package/validation/rules/NoFragmentCyclesRule.js +29 -0
  284. package/validation/rules/NoFragmentCyclesRule.mjs +28 -0
  285. package/validation/rules/NoUndefinedVariablesRule.d.ts +28 -0
  286. package/validation/rules/NoUndefinedVariablesRule.js +29 -0
  287. package/validation/rules/NoUndefinedVariablesRule.mjs +28 -0
  288. package/validation/rules/NoUnusedFragmentsRule.d.ts +28 -0
  289. package/validation/rules/NoUnusedFragmentsRule.js +29 -0
  290. package/validation/rules/NoUnusedFragmentsRule.mjs +28 -0
  291. package/validation/rules/NoUnusedVariablesRule.d.ts +29 -0
  292. package/validation/rules/NoUnusedVariablesRule.js +30 -0
  293. package/validation/rules/NoUnusedVariablesRule.mjs +29 -0
  294. package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +33 -0
  295. package/validation/rules/OverlappingFieldsCanBeMergedRule.js +45 -6
  296. package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +45 -6
  297. package/validation/rules/PossibleFragmentSpreadsRule.d.ts +36 -0
  298. package/validation/rules/PossibleFragmentSpreadsRule.js +37 -0
  299. package/validation/rules/PossibleFragmentSpreadsRule.mjs +36 -0
  300. package/validation/rules/PossibleTypeExtensionsRule.d.ts +21 -0
  301. package/validation/rules/PossibleTypeExtensionsRule.js +22 -0
  302. package/validation/rules/PossibleTypeExtensionsRule.mjs +21 -0
  303. package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +29 -3
  304. package/validation/rules/ProvidedRequiredArgumentsRule.js +30 -3
  305. package/validation/rules/ProvidedRequiredArgumentsRule.mjs +29 -3
  306. package/validation/rules/ScalarLeafsRule.d.ts +28 -0
  307. package/validation/rules/ScalarLeafsRule.js +29 -0
  308. package/validation/rules/ScalarLeafsRule.mjs +28 -0
  309. package/validation/rules/SingleFieldSubscriptionsRule.d.ts +33 -0
  310. package/validation/rules/SingleFieldSubscriptionsRule.js +34 -0
  311. package/validation/rules/SingleFieldSubscriptionsRule.mjs +33 -0
  312. package/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts +21 -0
  313. package/validation/rules/UniqueArgumentDefinitionNamesRule.js +22 -0
  314. package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +21 -0
  315. package/validation/rules/UniqueArgumentNamesRule.d.ts +28 -0
  316. package/validation/rules/UniqueArgumentNamesRule.js +29 -0
  317. package/validation/rules/UniqueArgumentNamesRule.mjs +28 -0
  318. package/validation/rules/UniqueDirectiveNamesRule.d.ts +21 -0
  319. package/validation/rules/UniqueDirectiveNamesRule.js +22 -0
  320. package/validation/rules/UniqueDirectiveNamesRule.mjs +21 -0
  321. package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +28 -0
  322. package/validation/rules/UniqueDirectivesPerLocationRule.js +29 -0
  323. package/validation/rules/UniqueDirectivesPerLocationRule.mjs +28 -0
  324. package/validation/rules/UniqueEnumValueNamesRule.d.ts +21 -0
  325. package/validation/rules/UniqueEnumValueNamesRule.js +22 -0
  326. package/validation/rules/UniqueEnumValueNamesRule.mjs +21 -0
  327. package/validation/rules/UniqueFieldDefinitionNamesRule.d.ts +21 -0
  328. package/validation/rules/UniqueFieldDefinitionNamesRule.js +22 -0
  329. package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +21 -0
  330. package/validation/rules/UniqueFragmentNamesRule.d.ts +28 -0
  331. package/validation/rules/UniqueFragmentNamesRule.js +29 -0
  332. package/validation/rules/UniqueFragmentNamesRule.mjs +28 -0
  333. package/validation/rules/UniqueInputFieldNamesRule.d.ts +32 -0
  334. package/validation/rules/UniqueInputFieldNamesRule.js +33 -0
  335. package/validation/rules/UniqueInputFieldNamesRule.mjs +32 -0
  336. package/validation/rules/UniqueOperationNamesRule.d.ts +28 -0
  337. package/validation/rules/UniqueOperationNamesRule.js +29 -0
  338. package/validation/rules/UniqueOperationNamesRule.mjs +28 -0
  339. package/validation/rules/UniqueOperationTypesRule.d.ts +21 -0
  340. package/validation/rules/UniqueOperationTypesRule.js +22 -0
  341. package/validation/rules/UniqueOperationTypesRule.mjs +21 -0
  342. package/validation/rules/UniqueTypeNamesRule.d.ts +21 -0
  343. package/validation/rules/UniqueTypeNamesRule.js +22 -0
  344. package/validation/rules/UniqueTypeNamesRule.mjs +21 -0
  345. package/validation/rules/UniqueVariableNamesRule.d.ts +28 -0
  346. package/validation/rules/UniqueVariableNamesRule.js +29 -0
  347. package/validation/rules/UniqueVariableNamesRule.mjs +28 -0
  348. package/validation/rules/ValuesOfCorrectTypeRule.d.ts +28 -0
  349. package/validation/rules/ValuesOfCorrectTypeRule.js +31 -0
  350. package/validation/rules/ValuesOfCorrectTypeRule.mjs +30 -0
  351. package/validation/rules/VariablesAreInputTypesRule.d.ts +32 -0
  352. package/validation/rules/VariablesAreInputTypesRule.js +33 -0
  353. package/validation/rules/VariablesAreInputTypesRule.mjs +32 -0
  354. package/validation/rules/VariablesInAllowedPositionRule.d.ts +28 -0
  355. package/validation/rules/VariablesInAllowedPositionRule.js +35 -1
  356. package/validation/rules/VariablesInAllowedPositionRule.mjs +34 -1
  357. package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +41 -0
  358. package/validation/rules/custom/NoDeprecatedCustomRule.js +42 -0
  359. package/validation/rules/custom/NoDeprecatedCustomRule.mjs +41 -0
  360. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +28 -0
  361. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +29 -0
  362. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +28 -0
  363. package/validation/specifiedRules.d.ts +2 -3
  364. package/validation/specifiedRules.js +2 -3
  365. package/validation/specifiedRules.mjs +2 -3
  366. package/validation/validate.d.ts +70 -9
  367. package/validation/validate.js +63 -7
  368. package/validation/validate.mjs +63 -7
  369. package/version.d.ts +3 -6
  370. package/version.js +6 -8
  371. package/version.mjs +5 -8
@@ -1,3 +1,4 @@
1
+ /** @category Types */
1
2
  import type { Maybe } from '../jsutils/Maybe';
2
3
  import type { ObjMap } from '../jsutils/ObjMap';
3
4
  import type { Path } from '../jsutils/Path';
@@ -24,9 +25,7 @@ import type {
24
25
  ValueNode,
25
26
  } from '../language/ast';
26
27
  import type { GraphQLSchema } from './schema';
27
- /**
28
- * These are all of the possible kinds of types.
29
- */
28
+ /** These are all of the possible kinds of types. */
30
29
  export declare type GraphQLType =
31
30
  | GraphQLScalarType
32
31
  | GraphQLObjectType
@@ -44,56 +43,555 @@ export declare type GraphQLType =
44
43
  | GraphQLInputObjectType
45
44
  | GraphQLList<GraphQLType>
46
45
  >;
46
+ /**
47
+ * Returns true when the value is any GraphQL type.
48
+ * @param type - The GraphQL type to inspect.
49
+ * @returns True when the value is any GraphQL type.
50
+ * @example
51
+ * ```ts
52
+ * import { buildSchema } from 'graphql/utilities';
53
+ * import { GraphQLList, GraphQLString, isType } from 'graphql/type';
54
+ *
55
+ * const schema = buildSchema(`
56
+ * type Query {
57
+ * name: String
58
+ * }
59
+ * `);
60
+ *
61
+ * isType(GraphQLString); // => true
62
+ * isType(new GraphQLList(GraphQLString)); // => true
63
+ * isType(schema.getType('Query')); // => true
64
+ * isType('String'); // => false
65
+ * ```
66
+ */
47
67
  export declare function isType(type: unknown): type is GraphQLType;
68
+ /**
69
+ * Returns the value as a GraphQL type, or throws if it is not one.
70
+ * @param type - The GraphQL type to inspect.
71
+ * @returns The value typed as a GraphQL type.
72
+ * @example
73
+ * ```ts
74
+ * import { buildSchema } from 'graphql/utilities';
75
+ * import { assertType } from 'graphql/type';
76
+ *
77
+ * const schema = buildSchema(`
78
+ * type Query {
79
+ * name: String
80
+ * }
81
+ * `);
82
+ *
83
+ * const queryType = assertType(schema.getType('Query'));
84
+ *
85
+ * queryType.toString(); // => 'Query'
86
+ * assertType('Query'); // throws an error
87
+ * ```
88
+ */
48
89
  export declare function assertType(type: unknown): GraphQLType;
49
90
  /**
50
91
  * There are predicates for each kind of GraphQL type.
92
+ * @param type - The GraphQL type to inspect.
93
+ * @returns True when the value is a GraphQLScalarType.
94
+ * @example
95
+ * ```ts
96
+ * import { buildSchema } from 'graphql/utilities';
97
+ * import { isScalarType } from 'graphql/type';
98
+ *
99
+ * const schema = buildSchema(`
100
+ * scalar DateTime
101
+ *
102
+ * type Query {
103
+ * createdAt: DateTime
104
+ * }
105
+ * `);
106
+ *
107
+ * isScalarType(schema.getType('DateTime')); // => true
108
+ * isScalarType(schema.getType('Query')); // => false
109
+ * ```
51
110
  */
52
111
  export declare function isScalarType(type: unknown): type is GraphQLScalarType;
112
+ /**
113
+ * Returns the value as a GraphQLScalarType, or throws if it is not one.
114
+ * @param type - The GraphQL type to inspect.
115
+ * @returns The value typed as a GraphQLScalarType.
116
+ * @example
117
+ * ```ts
118
+ * import { buildSchema } from 'graphql/utilities';
119
+ * import { assertScalarType } from 'graphql/type';
120
+ *
121
+ * const schema = buildSchema(`
122
+ * scalar DateTime
123
+ *
124
+ * type Query {
125
+ * createdAt: DateTime
126
+ * }
127
+ * `);
128
+ *
129
+ * const dateTimeType = assertScalarType(schema.getType('DateTime'));
130
+ *
131
+ * dateTimeType.name; // => 'DateTime'
132
+ * assertScalarType(schema.getType('Query')); // throws an error
133
+ * ```
134
+ */
53
135
  export declare function assertScalarType(type: unknown): GraphQLScalarType;
136
+ /**
137
+ * Returns true when the value is a GraphQLObjectType.
138
+ * @param type - The GraphQL type to inspect.
139
+ * @returns True when the value is a GraphQLObjectType.
140
+ * @example
141
+ * ```ts
142
+ * import { buildSchema } from 'graphql/utilities';
143
+ * import { isObjectType } from 'graphql/type';
144
+ *
145
+ * const schema = buildSchema(`
146
+ * input ReviewInput {
147
+ * stars: Int!
148
+ * }
149
+ *
150
+ * type User {
151
+ * name: String
152
+ * }
153
+ *
154
+ * type Query {
155
+ * user: User
156
+ * }
157
+ * `);
158
+ *
159
+ * isObjectType(schema.getType('User')); // => true
160
+ * isObjectType(schema.getType('ReviewInput')); // => false
161
+ * ```
162
+ */
54
163
  export declare function isObjectType(type: unknown): type is GraphQLObjectType;
164
+ /**
165
+ * Returns the value as a GraphQLObjectType, or throws if it is not one.
166
+ * @param type - The GraphQL type to inspect.
167
+ * @returns The value typed as a GraphQLObjectType.
168
+ * @example
169
+ * ```ts
170
+ * import { buildSchema } from 'graphql/utilities';
171
+ * import { assertObjectType } from 'graphql/type';
172
+ *
173
+ * const schema = buildSchema(`
174
+ * input ReviewInput {
175
+ * stars: Int!
176
+ * }
177
+ *
178
+ * type User {
179
+ * name: String
180
+ * }
181
+ *
182
+ * type Query {
183
+ * user: User
184
+ * }
185
+ * `);
186
+ *
187
+ * const userType = assertObjectType(schema.getType('User'));
188
+ *
189
+ * Object.keys(userType.getFields()); // => ['name']
190
+ * assertObjectType(schema.getType('ReviewInput')); // throws an error
191
+ * ```
192
+ */
55
193
  export declare function assertObjectType(type: unknown): GraphQLObjectType;
194
+ /**
195
+ * Returns true when the value is a GraphQLInterfaceType.
196
+ * @param type - The GraphQL type to inspect.
197
+ * @returns True when the value is a GraphQLInterfaceType.
198
+ * @example
199
+ * ```ts
200
+ * import { buildSchema } from 'graphql/utilities';
201
+ * import { isInterfaceType } from 'graphql/type';
202
+ *
203
+ * const schema = buildSchema(`
204
+ * interface Node {
205
+ * id: ID!
206
+ * }
207
+ *
208
+ * type User implements Node {
209
+ * id: ID!
210
+ * }
211
+ *
212
+ * type Query {
213
+ * node: Node
214
+ * }
215
+ * `);
216
+ *
217
+ * isInterfaceType(schema.getType('Node')); // => true
218
+ * isInterfaceType(schema.getType('User')); // => false
219
+ * ```
220
+ */
56
221
  export declare function isInterfaceType(
57
222
  type: unknown,
58
223
  ): type is GraphQLInterfaceType;
224
+ /**
225
+ * Returns the value as a GraphQLInterfaceType, or throws if it is not one.
226
+ * @param type - The GraphQL type to inspect.
227
+ * @returns The value typed as a GraphQLInterfaceType.
228
+ * @example
229
+ * ```ts
230
+ * import { buildSchema } from 'graphql/utilities';
231
+ * import { assertInterfaceType } from 'graphql/type';
232
+ *
233
+ * const schema = buildSchema(`
234
+ * interface Node {
235
+ * id: ID!
236
+ * }
237
+ *
238
+ * type User implements Node {
239
+ * id: ID!
240
+ * }
241
+ *
242
+ * type Query {
243
+ * node: Node
244
+ * }
245
+ * `);
246
+ *
247
+ * const nodeType = assertInterfaceType(schema.getType('Node'));
248
+ *
249
+ * nodeType.name; // => 'Node'
250
+ * assertInterfaceType(schema.getType('User')); // throws an error
251
+ * ```
252
+ */
59
253
  export declare function assertInterfaceType(
60
254
  type: unknown,
61
255
  ): GraphQLInterfaceType;
256
+ /**
257
+ * Returns true when the value is a GraphQLUnionType.
258
+ * @param type - The GraphQL type to inspect.
259
+ * @returns True when the value is a GraphQLUnionType.
260
+ * @example
261
+ * ```ts
262
+ * import { buildSchema } from 'graphql/utilities';
263
+ * import { isUnionType } from 'graphql/type';
264
+ *
265
+ * const schema = buildSchema(`
266
+ * type Photo {
267
+ * url: String!
268
+ * }
269
+ *
270
+ * type Video {
271
+ * url: String!
272
+ * }
273
+ *
274
+ * union Media = Photo | Video
275
+ *
276
+ * type Query {
277
+ * media: [Media]
278
+ * }
279
+ * `);
280
+ *
281
+ * isUnionType(schema.getType('Media')); // => true
282
+ * isUnionType(schema.getType('Photo')); // => false
283
+ * ```
284
+ */
62
285
  export declare function isUnionType(type: unknown): type is GraphQLUnionType;
286
+ /**
287
+ * Returns the value as a GraphQLUnionType, or throws if it is not one.
288
+ * @param type - The GraphQL type to inspect.
289
+ * @returns The value typed as a GraphQLUnionType.
290
+ * @example
291
+ * ```ts
292
+ * import { buildSchema } from 'graphql/utilities';
293
+ * import { assertUnionType } from 'graphql/type';
294
+ *
295
+ * const schema = buildSchema(`
296
+ * type Photo {
297
+ * url: String!
298
+ * }
299
+ *
300
+ * type Video {
301
+ * url: String!
302
+ * }
303
+ *
304
+ * union Media = Photo | Video
305
+ *
306
+ * type Query {
307
+ * media: [Media]
308
+ * }
309
+ * `);
310
+ *
311
+ * const mediaType = assertUnionType(schema.getType('Media'));
312
+ *
313
+ * mediaType.getTypes().map((type) => type.name); // => ['Photo', 'Video']
314
+ * assertUnionType(schema.getType('Photo')); // throws an error
315
+ * ```
316
+ */
63
317
  export declare function assertUnionType(type: unknown): GraphQLUnionType;
318
+ /**
319
+ * Returns true when the value is a GraphQLEnumType.
320
+ * @param type - The GraphQL type to inspect.
321
+ * @returns True when the value is a GraphQLEnumType.
322
+ * @example
323
+ * ```ts
324
+ * import { buildSchema } from 'graphql/utilities';
325
+ * import { isEnumType } from 'graphql/type';
326
+ *
327
+ * const schema = buildSchema(`
328
+ * enum Episode {
329
+ * NEW_HOPE
330
+ * EMPIRE
331
+ * }
332
+ *
333
+ * type Query {
334
+ * favoriteEpisode: Episode
335
+ * }
336
+ * `);
337
+ *
338
+ * isEnumType(schema.getType('Episode')); // => true
339
+ * isEnumType(schema.getType('Query')); // => false
340
+ * ```
341
+ */
64
342
  export declare function isEnumType(type: unknown): type is GraphQLEnumType;
343
+ /**
344
+ * Returns the value as a GraphQLEnumType, or throws if it is not one.
345
+ * @param type - The GraphQL type to inspect.
346
+ * @returns The value typed as a GraphQLEnumType.
347
+ * @example
348
+ * ```ts
349
+ * import { buildSchema } from 'graphql/utilities';
350
+ * import { assertEnumType } from 'graphql/type';
351
+ *
352
+ * const schema = buildSchema(`
353
+ * enum Episode {
354
+ * NEW_HOPE
355
+ * EMPIRE
356
+ * }
357
+ *
358
+ * type Query {
359
+ * favoriteEpisode: Episode
360
+ * }
361
+ * `);
362
+ *
363
+ * const episodeType = assertEnumType(schema.getType('Episode'));
364
+ *
365
+ * episodeType.getValues().map((value) => value.name); // => ['NEW_HOPE', 'EMPIRE']
366
+ * assertEnumType(schema.getType('Query')); // throws an error
367
+ * ```
368
+ */
65
369
  export declare function assertEnumType(type: unknown): GraphQLEnumType;
370
+ /**
371
+ * Returns true when the value is a GraphQLInputObjectType.
372
+ * @param type - The GraphQL type to inspect.
373
+ * @returns True when the value is a GraphQLInputObjectType.
374
+ * @example
375
+ * ```ts
376
+ * import { buildSchema } from 'graphql/utilities';
377
+ * import { isInputObjectType } from 'graphql/type';
378
+ *
379
+ * const schema = buildSchema(`
380
+ * input ReviewInput {
381
+ * stars: Int!
382
+ * }
383
+ *
384
+ * type Review {
385
+ * stars: Int!
386
+ * }
387
+ *
388
+ * type Query {
389
+ * review(input: ReviewInput): Review
390
+ * }
391
+ * `);
392
+ *
393
+ * isInputObjectType(schema.getType('ReviewInput')); // => true
394
+ * isInputObjectType(schema.getType('Review')); // => false
395
+ * ```
396
+ */
66
397
  export declare function isInputObjectType(
67
398
  type: unknown,
68
399
  ): type is GraphQLInputObjectType;
400
+ /**
401
+ * Returns the value as a GraphQLInputObjectType, or throws if it is not one.
402
+ * @param type - The GraphQL type to inspect.
403
+ * @returns The value typed as a GraphQLInputObjectType.
404
+ * @example
405
+ * ```ts
406
+ * import { buildSchema } from 'graphql/utilities';
407
+ * import { assertInputObjectType } from 'graphql/type';
408
+ *
409
+ * const schema = buildSchema(`
410
+ * input ReviewInput {
411
+ * stars: Int!
412
+ * }
413
+ *
414
+ * type Review {
415
+ * stars: Int!
416
+ * }
417
+ *
418
+ * type Query {
419
+ * review(input: ReviewInput): Review
420
+ * }
421
+ * `);
422
+ *
423
+ * const inputType = assertInputObjectType(schema.getType('ReviewInput'));
424
+ *
425
+ * Object.keys(inputType.getFields()); // => ['stars']
426
+ * assertInputObjectType(schema.getType('Review')); // throws an error
427
+ * ```
428
+ */
69
429
  export declare function assertInputObjectType(
70
430
  type: unknown,
71
431
  ): GraphQLInputObjectType;
432
+ /**
433
+ * Returns true when the value is a GraphQLList.
434
+ * @param type - The GraphQL type to inspect.
435
+ * @returns True when the value is a GraphQLList.
436
+ * @example
437
+ * ```ts
438
+ * import { buildSchema } from 'graphql/utilities';
439
+ * import { GraphQLList, GraphQLString, isListType } from 'graphql/type';
440
+ *
441
+ * const schema = buildSchema(`
442
+ * type Query {
443
+ * tags: [String!]!
444
+ * }
445
+ * `);
446
+ *
447
+ * const tagsField = schema.getQueryType()?.getFields().tags;
448
+ *
449
+ * isListType(new GraphQLList(GraphQLString)); // => true
450
+ * isListType(GraphQLString); // => false
451
+ * isListType(tagsField?.type); // => false
452
+ * ```
453
+ */
72
454
  export declare function isListType(
73
455
  type: GraphQLInputType,
74
456
  ): type is GraphQLList<GraphQLInputType>;
457
+ /**
458
+ * Returns true when the output type is a GraphQLList.
459
+ * @param type - The GraphQL output type to inspect.
460
+ * @returns True when the output type is a list type.
461
+ * @example
462
+ * ```ts
463
+ * import { buildSchema } from 'graphql/utilities';
464
+ * import { getNullableType, isListType } from 'graphql/type';
465
+ *
466
+ * const schema = buildSchema(`
467
+ * type Query {
468
+ * tags: [String!]!
469
+ * }
470
+ * `);
471
+ *
472
+ * const tagsField = schema.getQueryType()?.getFields().tags;
473
+ * const nullableTagsType = getNullableType(tagsField?.type);
474
+ *
475
+ * isListType(nullableTagsType); // => true
476
+ * ```
477
+ */
75
478
  export declare function isListType(
76
479
  type: GraphQLOutputType,
77
480
  ): type is GraphQLList<GraphQLOutputType>;
481
+ /**
482
+ * Returns true when the value is a GraphQLList.
483
+ * @param type - The value to inspect.
484
+ * @returns True when the value is a list type.
485
+ * @example
486
+ * ```ts
487
+ * import { isListType } from 'graphql/type';
488
+ *
489
+ * isListType('[String]'); // => false
490
+ * isListType(null); // => false
491
+ * ```
492
+ */
78
493
  export declare function isListType(
79
494
  type: unknown,
80
495
  ): type is GraphQLList<GraphQLType>;
496
+ /**
497
+ * Returns the value as a GraphQLList, or throws if it is not one.
498
+ * @param type - The GraphQL type to inspect.
499
+ * @returns The value typed as a GraphQLList.
500
+ * @example
501
+ * ```ts
502
+ * import { GraphQLList, GraphQLString, assertListType } from 'graphql/type';
503
+ *
504
+ * const listType = assertListType(new GraphQLList(GraphQLString));
505
+ *
506
+ * listType.ofType; // => GraphQLString
507
+ * assertListType(GraphQLString); // throws an error
508
+ * ```
509
+ */
81
510
  export declare function assertListType(type: unknown): GraphQLList<GraphQLType>;
511
+ /**
512
+ * Returns true when the value is a GraphQLNonNull.
513
+ * @param type - The GraphQL type to inspect.
514
+ * @returns True when the value is a GraphQLNonNull.
515
+ * @example
516
+ * ```ts
517
+ * import { buildSchema } from 'graphql/utilities';
518
+ * import { GraphQLNonNull, GraphQLString, isNonNullType } from 'graphql/type';
519
+ *
520
+ * const schema = buildSchema(`
521
+ * type Query {
522
+ * name: String!
523
+ * nickname: String
524
+ * }
525
+ * `);
526
+ *
527
+ * const fields = schema.getQueryType()?.getFields();
528
+ *
529
+ * isNonNullType(new GraphQLNonNull(GraphQLString)); // => true
530
+ * isNonNullType(fields?.name.type); // => true
531
+ * isNonNullType(fields?.nickname.type); // => false
532
+ * ```
533
+ */
82
534
  export declare function isNonNullType(
83
535
  type: GraphQLInputType,
84
536
  ): type is GraphQLNonNull<GraphQLInputType>;
537
+ /**
538
+ * Returns true when the output type is a GraphQLNonNull.
539
+ * @param type - The GraphQL output type to inspect.
540
+ * @returns True when the output type is a non-null type.
541
+ * @example
542
+ * ```ts
543
+ * import { buildSchema } from 'graphql/utilities';
544
+ * import { isNonNullType } from 'graphql/type';
545
+ *
546
+ * const schema = buildSchema(`
547
+ * type Query {
548
+ * name: String!
549
+ * nickname: String
550
+ * }
551
+ * `);
552
+ *
553
+ * const fields = schema.getQueryType()?.getFields();
554
+ *
555
+ * isNonNullType(fields?.name.type); // => true
556
+ * isNonNullType(fields?.nickname.type); // => false
557
+ * ```
558
+ */
85
559
  export declare function isNonNullType(
86
560
  type: GraphQLOutputType,
87
561
  ): type is GraphQLNonNull<GraphQLOutputType>;
562
+ /**
563
+ * Returns true when the value is a GraphQLNonNull.
564
+ * @param type - The value to inspect.
565
+ * @returns True when the value is a non-null type.
566
+ * @example
567
+ * ```ts
568
+ * import { isNonNullType } from 'graphql/type';
569
+ *
570
+ * isNonNullType('String!'); // => false
571
+ * isNonNullType(null); // => false
572
+ * ```
573
+ */
88
574
  export declare function isNonNullType(
89
575
  type: unknown,
90
576
  ): type is GraphQLNonNull<GraphQLType>;
577
+ /**
578
+ * Returns the value as a GraphQLNonNull, or throws if it is not one.
579
+ * @param type - The GraphQL type to inspect.
580
+ * @returns The value typed as a GraphQLNonNull.
581
+ * @example
582
+ * ```ts
583
+ * import { GraphQLNonNull, GraphQLString, assertNonNullType } from 'graphql/type';
584
+ *
585
+ * const nonNullType = assertNonNullType(new GraphQLNonNull(GraphQLString));
586
+ *
587
+ * nonNullType.ofType; // => GraphQLString
588
+ * assertNonNullType(GraphQLString); // throws an error
589
+ * ```
590
+ */
91
591
  export declare function assertNonNullType(
92
592
  type: unknown,
93
593
  ): GraphQLNonNull<GraphQLType>;
94
- /**
95
- * These types may be used as input types for arguments and directives.
96
- */
594
+ /** These types may be used as input types for arguments and directives. */
97
595
  export declare type GraphQLInputType =
98
596
  | GraphQLScalarType
99
597
  | GraphQLEnumType
@@ -105,11 +603,65 @@ export declare type GraphQLInputType =
105
603
  | GraphQLInputObjectType
106
604
  | GraphQLList<GraphQLInputType>
107
605
  >;
606
+ /**
607
+ * Returns true when the value can be used as a GraphQL input type.
608
+ * @param type - The GraphQL type to inspect.
609
+ * @returns True when the value can be used as a GraphQL input type.
610
+ * @example
611
+ * ```ts
612
+ * import { buildSchema } from 'graphql/utilities';
613
+ * import { isInputType } from 'graphql/type';
614
+ *
615
+ * const schema = buildSchema(`
616
+ * input ReviewInput {
617
+ * stars: Int!
618
+ * }
619
+ *
620
+ * type Review {
621
+ * stars: Int!
622
+ * }
623
+ *
624
+ * type Query {
625
+ * review(input: ReviewInput): Review
626
+ * }
627
+ * `);
628
+ *
629
+ * isInputType(schema.getType('ReviewInput')); // => true
630
+ * isInputType(schema.getType('Review')); // => false
631
+ * ```
632
+ */
108
633
  export declare function isInputType(type: unknown): type is GraphQLInputType;
109
- export declare function assertInputType(type: unknown): GraphQLInputType;
110
634
  /**
111
- * These types may be used as output types as the result of fields.
635
+ * Returns the value as a GraphQL input type, or throws if it is not one.
636
+ * @param type - The GraphQL type to inspect.
637
+ * @returns The value typed as a GraphQL input type.
638
+ * @example
639
+ * ```ts
640
+ * import { buildSchema } from 'graphql/utilities';
641
+ * import { assertInputType } from 'graphql/type';
642
+ *
643
+ * const schema = buildSchema(`
644
+ * input ReviewInput {
645
+ * stars: Int!
646
+ * }
647
+ *
648
+ * type Review {
649
+ * stars: Int!
650
+ * }
651
+ *
652
+ * type Query {
653
+ * review(input: ReviewInput): Review
654
+ * }
655
+ * `);
656
+ *
657
+ * const inputType = assertInputType(schema.getType('ReviewInput'));
658
+ *
659
+ * inputType.toString(); // => 'ReviewInput'
660
+ * assertInputType(schema.getType('Review')); // throws an error
661
+ * ```
112
662
  */
663
+ export declare function assertInputType(type: unknown): GraphQLInputType;
664
+ /** These types may be used as output types as the result of fields. */
113
665
  export declare type GraphQLOutputType =
114
666
  | GraphQLScalarType
115
667
  | GraphQLObjectType
@@ -125,36 +677,266 @@ export declare type GraphQLOutputType =
125
677
  | GraphQLEnumType
126
678
  | GraphQLList<GraphQLOutputType>
127
679
  >;
680
+ /**
681
+ * Returns true when the value can be used as a GraphQL output type.
682
+ * @param type - The GraphQL type to inspect.
683
+ * @returns True when the value can be used as a GraphQL output type.
684
+ * @example
685
+ * ```ts
686
+ * import { buildSchema } from 'graphql/utilities';
687
+ * import { isOutputType } from 'graphql/type';
688
+ *
689
+ * const schema = buildSchema(`
690
+ * input ReviewInput {
691
+ * stars: Int!
692
+ * }
693
+ *
694
+ * type Review {
695
+ * stars: Int!
696
+ * }
697
+ *
698
+ * type Query {
699
+ * review(input: ReviewInput): Review
700
+ * }
701
+ * `);
702
+ *
703
+ * isOutputType(schema.getType('Review')); // => true
704
+ * isOutputType(schema.getType('ReviewInput')); // => false
705
+ * ```
706
+ */
128
707
  export declare function isOutputType(type: unknown): type is GraphQLOutputType;
129
- export declare function assertOutputType(type: unknown): GraphQLOutputType;
130
708
  /**
131
- * These types may describe types which may be leaf values.
709
+ * Returns the value as a GraphQL output type, or throws if it is not one.
710
+ * @param type - The GraphQL type to inspect.
711
+ * @returns The value typed as a GraphQL output type.
712
+ * @example
713
+ * ```ts
714
+ * import { buildSchema } from 'graphql/utilities';
715
+ * import { assertOutputType } from 'graphql/type';
716
+ *
717
+ * const schema = buildSchema(`
718
+ * input ReviewInput {
719
+ * stars: Int!
720
+ * }
721
+ *
722
+ * type Review {
723
+ * stars: Int!
724
+ * }
725
+ *
726
+ * type Query {
727
+ * review(input: ReviewInput): Review
728
+ * }
729
+ * `);
730
+ *
731
+ * const outputType = assertOutputType(schema.getType('Review'));
732
+ *
733
+ * outputType.toString(); // => 'Review'
734
+ * assertOutputType(schema.getType('ReviewInput')); // throws an error
735
+ * ```
132
736
  */
737
+ export declare function assertOutputType(type: unknown): GraphQLOutputType;
738
+ /** These types may describe types which may be leaf values. */
133
739
  export declare type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType;
740
+ /**
741
+ * Returns true when the value is a GraphQL scalar or enum type.
742
+ * @param type - The GraphQL type to inspect.
743
+ * @returns True when the value is a GraphQL scalar or enum type.
744
+ * @example
745
+ * ```ts
746
+ * import { buildSchema } from 'graphql/utilities';
747
+ * import { isLeafType } from 'graphql/type';
748
+ *
749
+ * const schema = buildSchema(`
750
+ * enum Episode {
751
+ * NEW_HOPE
752
+ * }
753
+ *
754
+ * type Review {
755
+ * stars: Int!
756
+ * }
757
+ *
758
+ * type Query {
759
+ * episode: Episode
760
+ * review: Review
761
+ * }
762
+ * `);
763
+ *
764
+ * isLeafType(schema.getType('Episode')); // => true
765
+ * isLeafType(schema.getType('String')); // => true
766
+ * isLeafType(schema.getType('Review')); // => false
767
+ * ```
768
+ */
134
769
  export declare function isLeafType(type: unknown): type is GraphQLLeafType;
135
- export declare function assertLeafType(type: unknown): GraphQLLeafType;
136
770
  /**
137
- * These types may describe the parent context of a selection set.
771
+ * Returns the value as a GraphQL leaf type, or throws if it is not one.
772
+ * @param type - The GraphQL type to inspect.
773
+ * @returns The value typed as a GraphQL leaf type.
774
+ * @example
775
+ * ```ts
776
+ * import { buildSchema } from 'graphql/utilities';
777
+ * import { assertLeafType } from 'graphql/type';
778
+ *
779
+ * const schema = buildSchema(`
780
+ * enum Episode {
781
+ * NEW_HOPE
782
+ * }
783
+ *
784
+ * type Review {
785
+ * stars: Int!
786
+ * }
787
+ *
788
+ * type Query {
789
+ * episode: Episode
790
+ * review: Review
791
+ * }
792
+ * `);
793
+ *
794
+ * const episodeType = assertLeafType(schema.getType('Episode'));
795
+ *
796
+ * episodeType.toString(); // => 'Episode'
797
+ * assertLeafType(schema.getType('Review')); // throws an error
798
+ * ```
138
799
  */
800
+ export declare function assertLeafType(type: unknown): GraphQLLeafType;
801
+ /** These types may describe the parent context of a selection set. */
139
802
  export declare type GraphQLCompositeType =
140
803
  | GraphQLObjectType
141
804
  | GraphQLInterfaceType
142
805
  | GraphQLUnionType;
806
+ /**
807
+ * Returns true when the value is a GraphQL object, interface, or union type.
808
+ * @param type - The GraphQL type to inspect.
809
+ * @returns True when the value is a GraphQL object, interface, or union type.
810
+ * @example
811
+ * ```ts
812
+ * import { buildSchema } from 'graphql/utilities';
813
+ * import { isCompositeType } from 'graphql/type';
814
+ *
815
+ * const schema = buildSchema(`
816
+ * interface Node {
817
+ * id: ID!
818
+ * }
819
+ *
820
+ * type User implements Node {
821
+ * id: ID!
822
+ * }
823
+ *
824
+ * union SearchResult = User
825
+ *
826
+ * type Query {
827
+ * node: Node
828
+ * search: [SearchResult]
829
+ * }
830
+ * `);
831
+ *
832
+ * isCompositeType(schema.getType('User')); // => true
833
+ * isCompositeType(schema.getType('Node')); // => true
834
+ * isCompositeType(schema.getType('SearchResult')); // => true
835
+ * isCompositeType(schema.getType('String')); // => false
836
+ * ```
837
+ */
143
838
  export declare function isCompositeType(
144
839
  type: unknown,
145
840
  ): type is GraphQLCompositeType;
841
+ /**
842
+ * Returns the value as a GraphQL composite type, or throws if it is not one.
843
+ * @param type - The GraphQL type to inspect.
844
+ * @returns The value typed as a GraphQL composite type.
845
+ * @example
846
+ * ```ts
847
+ * import { buildSchema } from 'graphql/utilities';
848
+ * import { assertCompositeType } from 'graphql/type';
849
+ *
850
+ * const schema = buildSchema(`
851
+ * interface Node {
852
+ * id: ID!
853
+ * }
854
+ *
855
+ * type User implements Node {
856
+ * id: ID!
857
+ * }
858
+ *
859
+ * type Query {
860
+ * node: Node
861
+ * }
862
+ * `);
863
+ *
864
+ * const userType = assertCompositeType(schema.getType('User'));
865
+ *
866
+ * userType.toString(); // => 'User'
867
+ * assertCompositeType(schema.getType('String')); // throws an error
868
+ * ```
869
+ */
146
870
  export declare function assertCompositeType(
147
871
  type: unknown,
148
872
  ): GraphQLCompositeType;
149
- /**
150
- * These types may describe the parent context of a selection set.
151
- */
873
+ /** These types may describe the parent context of a selection set. */
152
874
  export declare type GraphQLAbstractType =
153
875
  | GraphQLInterfaceType
154
876
  | GraphQLUnionType;
877
+ /**
878
+ * Returns true when the value is a GraphQL interface or union type.
879
+ * @param type - The GraphQL type to inspect.
880
+ * @returns True when the value is a GraphQL interface or union type.
881
+ * @example
882
+ * ```ts
883
+ * import { buildSchema } from 'graphql/utilities';
884
+ * import { isAbstractType } from 'graphql/type';
885
+ *
886
+ * const schema = buildSchema(`
887
+ * interface Node {
888
+ * id: ID!
889
+ * }
890
+ *
891
+ * type User implements Node {
892
+ * id: ID!
893
+ * }
894
+ *
895
+ * union SearchResult = User
896
+ *
897
+ * type Query {
898
+ * node: Node
899
+ * search: [SearchResult]
900
+ * }
901
+ * `);
902
+ *
903
+ * isAbstractType(schema.getType('Node')); // => true
904
+ * isAbstractType(schema.getType('SearchResult')); // => true
905
+ * isAbstractType(schema.getType('User')); // => false
906
+ * ```
907
+ */
155
908
  export declare function isAbstractType(
156
909
  type: unknown,
157
910
  ): type is GraphQLAbstractType;
911
+ /**
912
+ * Returns the value as a GraphQL abstract type, or throws if it is not one.
913
+ * @param type - The GraphQL type to inspect.
914
+ * @returns The value typed as a GraphQL abstract type.
915
+ * @example
916
+ * ```ts
917
+ * import { buildSchema } from 'graphql/utilities';
918
+ * import { assertAbstractType } from 'graphql/type';
919
+ *
920
+ * const schema = buildSchema(`
921
+ * interface Node {
922
+ * id: ID!
923
+ * }
924
+ *
925
+ * type User implements Node {
926
+ * id: ID!
927
+ * }
928
+ *
929
+ * type Query {
930
+ * node: Node
931
+ * }
932
+ * `);
933
+ *
934
+ * const nodeType = assertAbstractType(schema.getType('Node'));
935
+ *
936
+ * nodeType.toString(); // => 'Node'
937
+ * assertAbstractType(schema.getType('User')); // throws an error
938
+ * ```
939
+ */
158
940
  export declare function assertAbstractType(type: unknown): GraphQLAbstractType;
159
941
  /**
160
942
  * List Type Wrapper
@@ -162,9 +944,8 @@ export declare function assertAbstractType(type: unknown): GraphQLAbstractType;
162
944
  * A list is a wrapping type which points to another type.
163
945
  * Lists are often created within the context of defining the fields of
164
946
  * an object type.
165
- *
166
- * Example:
167
- *
947
+ * @typeParam T - The GraphQL type wrapped by this list type.
948
+ * @example
168
949
  * ```ts
169
950
  * const PersonType = new GraphQLObjectType({
170
951
  * name: 'Person',
@@ -176,10 +957,55 @@ export declare function assertAbstractType(type: unknown): GraphQLAbstractType;
176
957
  * ```
177
958
  */
178
959
  export declare class GraphQLList<T extends GraphQLType> {
960
+ /** The type wrapped by this list or non-null type. */
179
961
  readonly ofType: T;
962
+ /**
963
+ * Creates a GraphQLList instance.
964
+ * @param ofType - The type to wrap.
965
+ * @example
966
+ * ```ts
967
+ * import { GraphQLList, GraphQLString } from 'graphql/type';
968
+ *
969
+ * const stringList = new GraphQLList(GraphQLString);
970
+ *
971
+ * stringList.ofType; // => GraphQLString
972
+ * String(stringList); // => '[String]'
973
+ * ```
974
+ */
180
975
  constructor(ofType: T);
976
+ /**
977
+ * Returns the value used by `Object.prototype.toString`.
978
+ * @returns The built-in string tag for this object.
979
+ */
181
980
  get [Symbol.toStringTag](): string;
981
+ /**
982
+ * Returns this wrapping type as a GraphQL type-reference string.
983
+ * @returns The GraphQL type-reference string.
984
+ * @example
985
+ * ```ts
986
+ * import { GraphQLList, GraphQLNonNull, GraphQLString } from 'graphql/type';
987
+ *
988
+ * const stringList = new GraphQLList(GraphQLString);
989
+ * const requiredStringList = new GraphQLList(new GraphQLNonNull(GraphQLString));
990
+ *
991
+ * stringList.toString(); // => '[String]'
992
+ * requiredStringList.toString(); // => '[String!]'
993
+ * ```
994
+ */
182
995
  toString(): string;
996
+ /**
997
+ * Returns the JSON representation used when this object is serialized.
998
+ * @returns The JSON-serializable representation.
999
+ * @example
1000
+ * ```ts
1001
+ * import { GraphQLList, GraphQLString } from 'graphql/type';
1002
+ *
1003
+ * const stringList = new GraphQLList(GraphQLString);
1004
+ *
1005
+ * stringList.toJSON(); // => '[String]'
1006
+ * JSON.stringify({ type: stringList }); // => '{"type":"[String]"}'
1007
+ * ```
1008
+ */
183
1009
  toJSON(): string;
184
1010
  }
185
1011
  /**
@@ -190,9 +1016,8 @@ export declare class GraphQLList<T extends GraphQLType> {
190
1016
  * an error is raised if this ever occurs during a request. It is useful for
191
1017
  * fields which you can make a strong guarantee on non-nullability, for example
192
1018
  * usually the id field of a database row will never be null.
193
- *
194
- * Example:
195
- *
1019
+ * @typeParam T - The nullable GraphQL type wrapped by this non-null type.
1020
+ * @example
196
1021
  * ```ts
197
1022
  * const RowType = new GraphQLObjectType({
198
1023
  * name: 'Row',
@@ -201,28 +1026,104 @@ export declare class GraphQLList<T extends GraphQLType> {
201
1026
  * })
202
1027
  * })
203
1028
  * ```
1029
+ *
204
1030
  * Note: the enforcement of non-nullability occurs within the executor.
205
1031
  */
206
1032
  export declare class GraphQLNonNull<T extends GraphQLNullableType> {
1033
+ /** The type wrapped by this list or non-null type. */
207
1034
  readonly ofType: T;
1035
+ /**
1036
+ * Creates a GraphQLNonNull instance.
1037
+ * @param ofType - The type to wrap.
1038
+ * @example
1039
+ * ```ts
1040
+ * import { GraphQLNonNull, GraphQLString } from 'graphql/type';
1041
+ *
1042
+ * const requiredString = new GraphQLNonNull(GraphQLString);
1043
+ *
1044
+ * requiredString.ofType; // => GraphQLString
1045
+ * String(requiredString); // => 'String!'
1046
+ * ```
1047
+ */
208
1048
  constructor(ofType: T);
1049
+ /**
1050
+ * Returns the value used by `Object.prototype.toString`.
1051
+ * @returns The built-in string tag for this object.
1052
+ */
209
1053
  get [Symbol.toStringTag](): string;
1054
+ /**
1055
+ * Returns this wrapping type as a GraphQL type-reference string.
1056
+ * @returns The GraphQL type-reference string.
1057
+ * @example
1058
+ * ```ts
1059
+ * import { GraphQLList, GraphQLNonNull, GraphQLString } from 'graphql/type';
1060
+ *
1061
+ * const requiredString = new GraphQLNonNull(GraphQLString);
1062
+ * const requiredStringList = new GraphQLNonNull(
1063
+ * new GraphQLList(GraphQLString),
1064
+ * );
1065
+ *
1066
+ * requiredString.toString(); // => 'String!'
1067
+ * requiredStringList.toString(); // => '[String]!'
1068
+ * ```
1069
+ */
210
1070
  toString(): string;
1071
+ /**
1072
+ * Returns the JSON representation used when this object is serialized.
1073
+ * @returns The JSON-serializable representation.
1074
+ * @example
1075
+ * ```ts
1076
+ * import { GraphQLNonNull, GraphQLString } from 'graphql/type';
1077
+ *
1078
+ * const requiredString = new GraphQLNonNull(GraphQLString);
1079
+ *
1080
+ * requiredString.toJSON(); // => 'String!'
1081
+ * JSON.stringify({ type: requiredString }); // => '{"type":"String!"}'
1082
+ * ```
1083
+ */
211
1084
  toJSON(): string;
212
- }
213
- /**
214
- * These types wrap and modify other types
215
- */
1085
+ }
1086
+ /** These types wrap and modify other types */
216
1087
  export declare type GraphQLWrappingType =
217
1088
  | GraphQLList<GraphQLType>
218
1089
  | GraphQLNonNull<GraphQLType>;
1090
+ /**
1091
+ * Returns true when the value is a GraphQL list or non-null wrapper type.
1092
+ * @param type - The GraphQL type to inspect.
1093
+ * @returns True when the value is a GraphQL list or non-null wrapper type.
1094
+ * @example
1095
+ * ```ts
1096
+ * import {
1097
+ * GraphQLList,
1098
+ * GraphQLNonNull,
1099
+ * GraphQLString,
1100
+ * isWrappingType,
1101
+ * } from 'graphql/type';
1102
+ *
1103
+ * isWrappingType(new GraphQLList(GraphQLString)); // => true
1104
+ * isWrappingType(new GraphQLNonNull(GraphQLString)); // => true
1105
+ * isWrappingType(GraphQLString); // => false
1106
+ * ```
1107
+ */
219
1108
  export declare function isWrappingType(
220
1109
  type: unknown,
221
1110
  ): type is GraphQLWrappingType;
222
- export declare function assertWrappingType(type: unknown): GraphQLWrappingType;
223
1111
  /**
224
- * These types can all accept null as a value.
1112
+ * Returns the value as a GraphQL wrapping type, or throws if it is not one.
1113
+ * @param type - The GraphQL type to inspect.
1114
+ * @returns The value typed as a GraphQL wrapping type.
1115
+ * @example
1116
+ * ```ts
1117
+ * import { GraphQLList, GraphQLString, assertWrappingType } from 'graphql/type';
1118
+ *
1119
+ * const wrappingType = assertWrappingType(new GraphQLList(GraphQLString));
1120
+ *
1121
+ * wrappingType.toString(); // => '[String]'
1122
+ * assertWrappingType(GraphQLString); // throws an error
1123
+ * ```
225
1124
  */
1125
+ export declare function assertWrappingType(type: unknown): GraphQLWrappingType;
1126
+ /** These types can all accept null as a value. */
226
1127
  export declare type GraphQLNullableType =
227
1128
  | GraphQLScalarType
228
1129
  | GraphQLObjectType
@@ -231,61 +1132,305 @@ export declare type GraphQLNullableType =
231
1132
  | GraphQLEnumType
232
1133
  | GraphQLInputObjectType
233
1134
  | GraphQLList<GraphQLType>;
1135
+ /**
1136
+ * Returns true when the value is a GraphQL type that can accept null.
1137
+ * @param type - The GraphQL type to inspect.
1138
+ * @returns True when the value is a GraphQL type that can accept null.
1139
+ * @example
1140
+ * ```ts
1141
+ * import { GraphQLNonNull, GraphQLString, isNullableType } from 'graphql/type';
1142
+ *
1143
+ * isNullableType(GraphQLString); // => true
1144
+ * isNullableType(new GraphQLNonNull(GraphQLString)); // => false
1145
+ * isNullableType(null); // => false
1146
+ * ```
1147
+ */
234
1148
  export declare function isNullableType(
235
1149
  type: unknown,
236
1150
  ): type is GraphQLNullableType;
1151
+ /**
1152
+ * Returns the value as a nullable GraphQL type, or throws if it is not one.
1153
+ * @param type - The GraphQL type to inspect.
1154
+ * @returns The value typed as a nullable GraphQL type.
1155
+ * @example
1156
+ * ```ts
1157
+ * import {
1158
+ * GraphQLNonNull,
1159
+ * GraphQLString,
1160
+ * assertNullableType,
1161
+ * } from 'graphql/type';
1162
+ *
1163
+ * const nullableType = assertNullableType(GraphQLString);
1164
+ *
1165
+ * nullableType; // => GraphQLString
1166
+ * assertNullableType(new GraphQLNonNull(GraphQLString)); // throws an error
1167
+ * ```
1168
+ */
237
1169
  export declare function assertNullableType(type: unknown): GraphQLNullableType;
1170
+ /**
1171
+ * Returns the nullable type.
1172
+ * @param type - The GraphQL type to inspect.
1173
+ * @returns The nullable type after removing one non-null wrapper, if present.
1174
+ * @example
1175
+ * ```ts
1176
+ * import { getNullableType } from 'graphql/type';
1177
+ *
1178
+ * getNullableType(null); // => undefined
1179
+ * getNullableType(undefined); // => undefined
1180
+ * ```
1181
+ */
238
1182
  export declare function getNullableType(type: undefined | null): void;
1183
+ /**
1184
+ * Returns the nullable type after removing one non-null wrapper.
1185
+ * @param type - A nullable type or non-null wrapper.
1186
+ * @returns The nullable type after removing one non-null wrapper, if present.
1187
+ * @typeParam T - The nullable GraphQL type returned after removing one non-null wrapper.
1188
+ * @example
1189
+ * ```ts
1190
+ * import {
1191
+ * GraphQLList,
1192
+ * GraphQLNonNull,
1193
+ * GraphQLString,
1194
+ * getNullableType,
1195
+ * } from 'graphql/type';
1196
+ *
1197
+ * const requiredString = new GraphQLNonNull(GraphQLString);
1198
+ * const stringList = new GraphQLList(GraphQLString);
1199
+ *
1200
+ * getNullableType(requiredString); // => GraphQLString
1201
+ * getNullableType(stringList); // => stringList
1202
+ * ```
1203
+ */
239
1204
  export declare function getNullableType<T extends GraphQLNullableType>(
240
1205
  type: T | GraphQLNonNull<T>,
241
1206
  ): T;
1207
+ /**
1208
+ * Returns the nullable type after removing one non-null wrapper.
1209
+ * @param type - The GraphQL type to inspect.
1210
+ * @returns The nullable type after removing one non-null wrapper, if present.
1211
+ * @example
1212
+ * ```ts
1213
+ * import {
1214
+ * GraphQLList,
1215
+ * GraphQLNonNull,
1216
+ * GraphQLString,
1217
+ * getNullableType,
1218
+ * } from 'graphql/type';
1219
+ *
1220
+ * const requiredStringList = new GraphQLNonNull(
1221
+ * new GraphQLList(GraphQLString),
1222
+ * );
1223
+ *
1224
+ * getNullableType(requiredStringList).toString(); // => '[String]'
1225
+ * getNullableType(GraphQLString); // => GraphQLString
1226
+ * ```
1227
+ */
242
1228
  export declare function getNullableType(
243
1229
  type: Maybe<GraphQLType>,
244
1230
  ): GraphQLNullableType | undefined;
245
- /**
246
- * These named types do not include modifiers like List or NonNull.
247
- */
1231
+ /** These named types do not include modifiers like List or NonNull. */
248
1232
  export declare type GraphQLNamedType =
249
1233
  | GraphQLNamedInputType
250
1234
  | GraphQLNamedOutputType;
1235
+ /** A named GraphQL type that can be used as an input type. */
251
1236
  export declare type GraphQLNamedInputType =
252
1237
  | GraphQLScalarType
253
1238
  | GraphQLEnumType
254
1239
  | GraphQLInputObjectType;
1240
+ /** A named GraphQL type that can be used as an output type. */
255
1241
  export declare type GraphQLNamedOutputType =
256
1242
  | GraphQLScalarType
257
1243
  | GraphQLObjectType
258
1244
  | GraphQLInterfaceType
259
1245
  | GraphQLUnionType
260
1246
  | GraphQLEnumType;
1247
+ /**
1248
+ * Returns true when the value is a GraphQL named type.
1249
+ * @param type - The GraphQL type to inspect.
1250
+ * @returns True when the value is a GraphQL named type.
1251
+ * @example
1252
+ * ```ts
1253
+ * import { GraphQLList, GraphQLString, isNamedType } from 'graphql/type';
1254
+ *
1255
+ * isNamedType(GraphQLString); // => true
1256
+ * isNamedType(new GraphQLList(GraphQLString)); // => false
1257
+ * isNamedType(null); // => false
1258
+ * ```
1259
+ */
261
1260
  export declare function isNamedType(type: unknown): type is GraphQLNamedType;
1261
+ /**
1262
+ * Returns the value as a GraphQL named type, or throws if it is not one.
1263
+ * @param type - The GraphQL type to inspect.
1264
+ * @returns The value typed as a GraphQL named type.
1265
+ * @example
1266
+ * ```ts
1267
+ * import { GraphQLList, GraphQLString, assertNamedType } from 'graphql/type';
1268
+ *
1269
+ * const namedType = assertNamedType(GraphQLString);
1270
+ *
1271
+ * namedType.name; // => 'String'
1272
+ * assertNamedType(new GraphQLList(GraphQLString)); // throws an error
1273
+ * ```
1274
+ */
262
1275
  export declare function assertNamedType(type: unknown): GraphQLNamedType;
1276
+ /**
1277
+ * Returns the named type.
1278
+ * @param type - The GraphQL type to inspect.
1279
+ * @returns The named type after unwrapping all list and non-null wrappers.
1280
+ * @example
1281
+ * ```ts
1282
+ * import { getNamedType } from 'graphql/type';
1283
+ *
1284
+ * getNamedType(null); // => undefined
1285
+ * getNamedType(undefined); // => undefined
1286
+ * ```
1287
+ */
263
1288
  export declare function getNamedType(type: undefined | null): void;
1289
+ /**
1290
+ * Returns the named input type after unwrapping all list and non-null wrappers.
1291
+ * @param type - The GraphQL input type to inspect.
1292
+ * @returns The named input type after unwrapping all wrappers.
1293
+ * @example
1294
+ * ```ts
1295
+ * import { buildSchema } from 'graphql/utilities';
1296
+ * import { getNamedType } from 'graphql/type';
1297
+ *
1298
+ * const schema = buildSchema(`
1299
+ * input ReviewInput {
1300
+ * stars: Int!
1301
+ * }
1302
+ *
1303
+ * type Query {
1304
+ * review(input: [ReviewInput!]!): Boolean
1305
+ * }
1306
+ * `);
1307
+ *
1308
+ * const inputArg = schema.getQueryType()?.getFields().review.args[0];
1309
+ *
1310
+ * getNamedType(inputArg?.type).toString(); // => 'ReviewInput'
1311
+ * ```
1312
+ */
264
1313
  export declare function getNamedType(
265
1314
  type: GraphQLInputType,
266
1315
  ): GraphQLNamedInputType;
1316
+ /**
1317
+ * Returns the named output type after unwrapping all list and non-null wrappers.
1318
+ * @param type - The GraphQL output type to inspect.
1319
+ * @returns The named output type after unwrapping all wrappers.
1320
+ * @example
1321
+ * ```ts
1322
+ * import { buildSchema } from 'graphql/utilities';
1323
+ * import { getNamedType } from 'graphql/type';
1324
+ *
1325
+ * const schema = buildSchema(`
1326
+ * type User {
1327
+ * name: String
1328
+ * }
1329
+ *
1330
+ * type Query {
1331
+ * users: [User!]!
1332
+ * }
1333
+ * `);
1334
+ *
1335
+ * const usersField = schema.getQueryType()?.getFields().users;
1336
+ *
1337
+ * getNamedType(usersField?.type).toString(); // => 'User'
1338
+ * ```
1339
+ */
267
1340
  export declare function getNamedType(
268
1341
  type: GraphQLOutputType,
269
1342
  ): GraphQLNamedOutputType;
1343
+ /**
1344
+ * Returns the named type after unwrapping all list and non-null wrappers.
1345
+ * @param type - The GraphQL type to inspect.
1346
+ * @returns The named type after unwrapping all wrappers.
1347
+ * @example
1348
+ * ```ts
1349
+ * import {
1350
+ * GraphQLList,
1351
+ * GraphQLNonNull,
1352
+ * GraphQLString,
1353
+ * getNamedType,
1354
+ * } from 'graphql/type';
1355
+ *
1356
+ * const nestedType = new GraphQLNonNull(
1357
+ * new GraphQLList(new GraphQLNonNull(GraphQLString)),
1358
+ * );
1359
+ *
1360
+ * getNamedType(nestedType); // => GraphQLString
1361
+ * ```
1362
+ */
270
1363
  export declare function getNamedType(type: GraphQLType): GraphQLNamedType;
1364
+ /**
1365
+ * Returns the named type after unwrapping all list and non-null wrappers.
1366
+ * @param type - The GraphQL type to inspect.
1367
+ * @returns The named type after unwrapping all wrappers, or undefined for nullish input.
1368
+ * @example
1369
+ * ```ts
1370
+ * import {
1371
+ * GraphQLList,
1372
+ * GraphQLString,
1373
+ * getNamedType,
1374
+ * } from 'graphql/type';
1375
+ *
1376
+ * getNamedType(new GraphQLList(GraphQLString)); // => GraphQLString
1377
+ * getNamedType(undefined); // => undefined
1378
+ * ```
1379
+ */
271
1380
  export declare function getNamedType(
272
1381
  type: Maybe<GraphQLType>,
273
1382
  ): GraphQLNamedType | undefined;
274
1383
  /**
275
1384
  * Used while defining GraphQL types to allow for circular references in
276
1385
  * otherwise immutable type definitions.
1386
+ * @typeParam T - The element type returned by the thunk or array.
277
1387
  */
278
1388
  export declare type ThunkReadonlyArray<T> =
279
1389
  | (() => ReadonlyArray<T>)
280
1390
  | ReadonlyArray<T>;
1391
+ /**
1392
+ * A thunk that resolves to an object map.
1393
+ * @typeParam T - Value type stored in the object map.
1394
+ */
281
1395
  export declare type ThunkObjMap<T> = (() => ObjMap<T>) | ObjMap<T>;
1396
+ /**
1397
+ * Resolves a thunked readonly array.
1398
+ * @param thunk - The thunk or value to resolve.
1399
+ * @returns The resolved readonly array.
1400
+ * @typeParam T - The element type resolved from the thunk or array.
1401
+ * @example
1402
+ * ```ts
1403
+ * import { GraphQLString, resolveReadonlyArrayThunk } from 'graphql/type';
1404
+ *
1405
+ * const lazyFields = resolveReadonlyArrayThunk(() => [GraphQLString]);
1406
+ * const fields = resolveReadonlyArrayThunk([GraphQLString]);
1407
+ *
1408
+ * lazyFields; // => [GraphQLString]
1409
+ * fields; // => [GraphQLString]
1410
+ * ```
1411
+ */
282
1412
  export declare function resolveReadonlyArrayThunk<T>(
283
1413
  thunk: ThunkReadonlyArray<T>,
284
1414
  ): ReadonlyArray<T>;
1415
+ /**
1416
+ * Resolves a thunked object map.
1417
+ * @param thunk - The thunk or value to resolve.
1418
+ * @returns The resolved object map.
1419
+ * @typeParam T - The object-map value type resolved from the thunk or map.
1420
+ * @example
1421
+ * ```ts
1422
+ * import { GraphQLString, resolveObjMapThunk } from 'graphql/type';
1423
+ *
1424
+ * const lazyFields = resolveObjMapThunk(() => ({ name: GraphQLString }));
1425
+ * const fields = resolveObjMapThunk({ name: GraphQLString });
1426
+ *
1427
+ * lazyFields.name; // => GraphQLString
1428
+ * fields.name; // => GraphQLString
1429
+ * ```
1430
+ */
285
1431
  export declare function resolveObjMapThunk<T>(thunk: ThunkObjMap<T>): ObjMap<T>;
286
1432
  /**
287
1433
  * Custom extensions
288
- *
289
1434
  * @remarks
290
1435
  * Use a unique identifier name for your extension, for example the name of
291
1436
  * your library or project. Do not use a shortened identifier as this increases
@@ -298,20 +1443,22 @@ export interface GraphQLScalarTypeExtensions {
298
1443
  /**
299
1444
  * Scalar Type Definition
300
1445
  *
301
- * The leaf values of any request and input values to arguments are
302
- * Scalars (or Enums) and are defined with a name and a series of functions
303
- * used to parse input from ast or variables and to ensure validity.
1446
+ * Scalar types define the leaf values of a GraphQL response and the input
1447
+ * values accepted by arguments and input object fields. A scalar type has a
1448
+ * name and coercion functions that validate and convert runtime values and
1449
+ * GraphQL literals.
304
1450
  *
305
1451
  * If a type's serialize function returns `null` or does not return a value
306
1452
  * (i.e. it returns `undefined`) then an error will be raised and a `null`
307
- * value will be returned in the response. It is always better to validate
308
- *
309
- * Example:
310
- *
1453
+ * value will be returned in the response. Prefer validating inputs before
1454
+ * execution so clients receive input diagnostics before result coercion fails.
1455
+ * @typeParam TInternal - The internal runtime representation accepted by this scalar.
1456
+ * @typeParam TExternal - The serialized representation exposed in GraphQL results.
1457
+ * @example
311
1458
  * ```ts
312
1459
  * const OddType = new GraphQLScalarType({
313
1460
  * name: 'Odd',
314
- * serialize(value) {
1461
+ * serialize: (value) => {
315
1462
  * if (!Number.isFinite(value)) {
316
1463
  * throw new Error(
317
1464
  * `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`,
@@ -330,34 +1477,167 @@ export declare class GraphQLScalarType<
330
1477
  TInternal = unknown,
331
1478
  TExternal = TInternal,
332
1479
  > {
1480
+ /** The GraphQL name for this schema element. */
333
1481
  name: string;
1482
+ /** Human-readable description for this schema element, if provided. */
334
1483
  description: Maybe<string>;
1484
+ /** URL identifying the behavior specified for this custom scalar. */
335
1485
  specifiedByURL: Maybe<string>;
1486
+ /** Function that converts internal values to externally visible scalar values. */
336
1487
  serialize: GraphQLScalarSerializer<TExternal>;
1488
+ /** Function that converts variable input into this scalar's internal value. */
337
1489
  parseValue: GraphQLScalarValueParser<TInternal>;
1490
+ /** Function that converts AST input literals into this scalar's internal value. */
338
1491
  parseLiteral: GraphQLScalarLiteralParser<TInternal>;
1492
+ /** Extension fields to include in the formatted result. */
339
1493
  extensions: Readonly<GraphQLScalarTypeExtensions>;
1494
+ /** AST node from which this schema element was built, if available. */
340
1495
  astNode: Maybe<ScalarTypeDefinitionNode>;
1496
+ /** AST extension nodes applied to this schema element. */
341
1497
  extensionASTNodes: ReadonlyArray<ScalarTypeExtensionNode>;
1498
+ /**
1499
+ * Creates a GraphQLScalarType instance.
1500
+ * @param config - Configuration describing this object.
1501
+ * @example
1502
+ * ```ts
1503
+ * import { Kind, parse } from 'graphql/language';
1504
+ * import { GraphQLScalarType } from 'graphql/type';
1505
+ *
1506
+ * const document = parse(`
1507
+ * "Odd integer values."
1508
+ * scalar Odd @specifiedBy(url: "https://example.com/odd")
1509
+ *
1510
+ * extend scalar Odd @specifiedBy(url: "https://example.com/odd-v2")
1511
+ * `);
1512
+ *
1513
+ * const Odd = new GraphQLScalarType({
1514
+ * name: 'Odd',
1515
+ * description: 'Odd integer values.',
1516
+ * specifiedByURL: 'https://example.com/odd',
1517
+ * serialize: (value) => {
1518
+ * if (typeof value !== 'number' || value % 2 === 0) {
1519
+ * throw new TypeError('Odd can only serialize odd numbers.');
1520
+ * }
1521
+ * return value;
1522
+ * },
1523
+ * parseValue: (value) => {
1524
+ * if (typeof value !== 'number' || value % 2 === 0) {
1525
+ * throw new TypeError('Odd can only parse odd numbers.');
1526
+ * }
1527
+ * return value;
1528
+ * },
1529
+ * parseLiteral: (ast) => {
1530
+ * if (ast.kind !== Kind.INT) {
1531
+ * throw new TypeError('Odd can only parse integer literals.');
1532
+ * }
1533
+ * const value = Number(ast.value);
1534
+ * if (value % 2 === 0) {
1535
+ * throw new TypeError('Odd can only parse odd integer literals.');
1536
+ * }
1537
+ * return value;
1538
+ * },
1539
+ * extensions: { numeric: true },
1540
+ * astNode: document.definitions[0],
1541
+ * extensionASTNodes: [ document.definitions[1] ],
1542
+ * });
1543
+ *
1544
+ * Odd.description; // => 'Odd integer values.'
1545
+ * Odd.specifiedByURL; // => 'https://example.com/odd'
1546
+ * Odd.serialize(3); // => 3
1547
+ * Odd.parseValue(5); // => 5
1548
+ * Odd.extensions; // => { numeric: true }
1549
+ * ```
1550
+ */
342
1551
  constructor(config: Readonly<GraphQLScalarTypeConfig<TInternal, TExternal>>);
1552
+ /**
1553
+ * Returns the value used by `Object.prototype.toString`.
1554
+ * @returns The built-in string tag for this object.
1555
+ */
343
1556
  get [Symbol.toStringTag](): string;
1557
+ /**
1558
+ * Returns a normalized configuration object for this object.
1559
+ * @returns A configuration object that can be used to recreate this object.
1560
+ * @example
1561
+ * ```ts
1562
+ * import { GraphQLScalarType } from 'graphql/type';
1563
+ *
1564
+ * const Url = new GraphQLScalarType({
1565
+ * name: 'Url',
1566
+ * description: 'An absolute URL string.',
1567
+ * specifiedByURL: 'https://url.spec.whatwg.org/',
1568
+ * });
1569
+ *
1570
+ * const config = Url.toConfig();
1571
+ * const UrlCopy = new GraphQLScalarType(config);
1572
+ *
1573
+ * config.name; // => 'Url'
1574
+ * config.specifiedByURL; // => 'https://url.spec.whatwg.org/'
1575
+ * UrlCopy.name; // => Url.name
1576
+ * ```
1577
+ */
344
1578
  toConfig(): GraphQLScalarTypeNormalizedConfig<TInternal, TExternal>;
1579
+ /**
1580
+ * Returns the schema coordinate identifying this scalar type.
1581
+ * @returns The schema coordinate for this scalar type.
1582
+ * @example
1583
+ * ```ts
1584
+ * import { GraphQLScalarType } from 'graphql/type';
1585
+ *
1586
+ * const DateTime = new GraphQLScalarType({ name: 'DateTime' });
1587
+ *
1588
+ * DateTime.toString(); // => 'DateTime'
1589
+ * String(DateTime); // => 'DateTime'
1590
+ * ```
1591
+ */
345
1592
  toString(): string;
1593
+ /**
1594
+ * Returns the JSON representation used when this object is serialized.
1595
+ * @returns The JSON-serializable representation.
1596
+ * @example
1597
+ * ```ts
1598
+ * import { GraphQLScalarType } from 'graphql/type';
1599
+ *
1600
+ * const DateTime = new GraphQLScalarType({ name: 'DateTime' });
1601
+ *
1602
+ * DateTime.toJSON(); // => 'DateTime'
1603
+ * JSON.stringify({ type: DateTime }); // => '{"type":"DateTime"}'
1604
+ * ```
1605
+ */
346
1606
  toJSON(): string;
347
1607
  }
1608
+ /**
1609
+ * Serializes a runtime value as a scalar output value.
1610
+ * @typeParam TExternal - The serialized representation returned for GraphQL results.
1611
+ */
348
1612
  export declare type GraphQLScalarSerializer<TExternal> = (
349
1613
  outputValue: unknown,
350
1614
  ) => TExternal;
1615
+ /**
1616
+ * Parses a runtime input value as a scalar input value.
1617
+ * @typeParam TInternal - The internal runtime representation produced from variable input.
1618
+ */
351
1619
  export declare type GraphQLScalarValueParser<TInternal> = (
352
1620
  inputValue: unknown,
353
1621
  ) => TInternal;
1622
+ /**
1623
+ * Parses a GraphQL value literal as a scalar input value.
1624
+ * @typeParam TInternal - The internal runtime representation produced from literal input.
1625
+ */
354
1626
  export declare type GraphQLScalarLiteralParser<TInternal> = (
355
1627
  valueNode: ValueNode,
356
1628
  variables?: Maybe<ObjMap<unknown>>,
357
1629
  ) => TInternal;
1630
+ /**
1631
+ * Configuration used to construct a GraphQLScalarType.
1632
+ * @typeParam TInternal - The internal runtime representation accepted by this scalar.
1633
+ * @typeParam TExternal - The serialized representation exposed in GraphQL results.
1634
+ */
358
1635
  export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
1636
+ /** The GraphQL name for this schema element. */
359
1637
  name: string;
1638
+ /** Human-readable description for this schema element, if provided. */
360
1639
  description?: Maybe<string>;
1640
+ /** URL identifying the behavior specified for this custom scalar. */
361
1641
  specifiedByURL?: Maybe<string>;
362
1642
  /** Serializes an internal value to include in a response. */
363
1643
  serialize?: GraphQLScalarSerializer<TExternal>;
@@ -365,8 +1645,11 @@ export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
365
1645
  parseValue?: GraphQLScalarValueParser<TInternal>;
366
1646
  /** Parses an externally provided literal value to use as an input. */
367
1647
  parseLiteral?: GraphQLScalarLiteralParser<TInternal>;
1648
+ /** Extension fields to include in the formatted result. */
368
1649
  extensions?: Maybe<Readonly<GraphQLScalarTypeExtensions>>;
1650
+ /** AST node from which this schema element was built, if available. */
369
1651
  astNode?: Maybe<ScalarTypeDefinitionNode>;
1652
+ /** AST extension nodes applied to this schema element. */
370
1653
  extensionASTNodes?: Maybe<ReadonlyArray<ScalarTypeExtensionNode>>;
371
1654
  }
372
1655
  interface GraphQLScalarTypeNormalizedConfig<TInternal, TExternal>
@@ -379,15 +1662,15 @@ interface GraphQLScalarTypeNormalizedConfig<TInternal, TExternal>
379
1662
  }
380
1663
  /**
381
1664
  * Custom extensions
382
- *
383
1665
  * @remarks
384
1666
  * Use a unique identifier name for your extension, for example the name of
385
1667
  * your library or project. Do not use a shortened identifier as this increases
386
1668
  * the risk of conflicts. We recommend you add at most one extension field,
387
1669
  * an object which can contain all the values you need.
388
- *
389
1670
  * We've provided these template arguments because this is an open type and
390
1671
  * you may find them useful.
1672
+ * @typeParam _TSource - Reserved source type parameter for extension typing.
1673
+ * @typeParam _TContext - Reserved context type parameter for extension typing.
391
1674
  */
392
1675
  export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
393
1676
  [attributeName: string]: unknown;
@@ -397,9 +1680,9 @@ export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
397
1680
  *
398
1681
  * Almost all of the GraphQL types you define will be object types. Object types
399
1682
  * have a name, but most importantly describe their fields.
400
- *
401
- * Example:
402
- *
1683
+ * @typeParam TSource - Source object type passed to resolvers.
1684
+ * @typeParam TContext - Context object type passed to resolvers.
1685
+ * @example
403
1686
  * ```ts
404
1687
  * const AddressType = new GraphQLObjectType({
405
1688
  * name: 'Address',
@@ -408,20 +1691,18 @@ export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
408
1691
  * number: { type: GraphQLInt },
409
1692
  * formatted: {
410
1693
  * type: GraphQLString,
411
- * resolve(obj) {
1694
+ * resolve: (obj) => {
412
1695
  * return obj.number + ' ' + obj.street
413
1696
  * }
414
1697
  * }
415
1698
  * }
416
1699
  * });
417
1700
  * ```
418
- *
1701
+ * @example
419
1702
  * When two types need to refer to each other, or a type needs to refer to
420
1703
  * itself in a field, you can use a function expression (aka a closure or a
421
1704
  * thunk) to supply the fields lazily.
422
1705
  *
423
- * Example:
424
- *
425
1706
  * ```ts
426
1707
  * const PersonType = new GraphQLObjectType({
427
1708
  * name: 'Person',
@@ -433,39 +1714,274 @@ export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
433
1714
  * ```
434
1715
  */
435
1716
  export declare class GraphQLObjectType<TSource = any, TContext = any> {
1717
+ /** The GraphQL name for this schema element. */
436
1718
  name: string;
1719
+ /** Human-readable description for this schema element, if provided. */
437
1720
  description: Maybe<string>;
1721
+ /** Predicate used to determine whether a runtime value belongs to this object type. */
438
1722
  isTypeOf: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
1723
+ /** Extension fields to include in the formatted result. */
439
1724
  extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>;
1725
+ /** AST node from which this schema element was built, if available. */
440
1726
  astNode: Maybe<ObjectTypeDefinitionNode>;
1727
+ /** AST extension nodes applied to this schema element. */
441
1728
  extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode>;
442
1729
  private _fields;
443
1730
  private _interfaces;
1731
+ /**
1732
+ * Creates a GraphQLObjectType instance.
1733
+ * @param config - Configuration describing this object.
1734
+ * @example
1735
+ * ```ts
1736
+ * // Configure an object type with interfaces, fields, arguments, and metadata.
1737
+ * import { parse } from 'graphql/language';
1738
+ * import {
1739
+ * GraphQLID,
1740
+ * GraphQLInterfaceType,
1741
+ * GraphQLNonNull,
1742
+ * GraphQLObjectType,
1743
+ * GraphQLString,
1744
+ * } from 'graphql/type';
1745
+ *
1746
+ * const document = parse(`
1747
+ * type User implements Node {
1748
+ * id: ID!
1749
+ * name(format: String = "short"): String
1750
+ * }
1751
+ *
1752
+ * extend type User {
1753
+ * displayName: String
1754
+ * }
1755
+ * `);
1756
+ * const definition = document.definitions[0];
1757
+ * const nameField = definition.fields[1];
1758
+ * const formatArg = nameField.arguments[0];
1759
+ *
1760
+ * const Node = new GraphQLInterfaceType({
1761
+ * name: 'Node',
1762
+ * fields: {
1763
+ * id: { type: new GraphQLNonNull(GraphQLID) },
1764
+ * },
1765
+ * });
1766
+ *
1767
+ * const User = new GraphQLObjectType({
1768
+ * name: 'User',
1769
+ * description: 'A registered user.',
1770
+ * interfaces: [Node],
1771
+ * fields: {
1772
+ * id: { type: new GraphQLNonNull(GraphQLID) },
1773
+ * name: {
1774
+ * description: 'The formatted user name.',
1775
+ * type: GraphQLString,
1776
+ * args: {
1777
+ * format: {
1778
+ * description: 'Controls the name format.',
1779
+ * type: GraphQLString,
1780
+ * defaultValue: 'short',
1781
+ * deprecationReason: 'Use locale instead.',
1782
+ * extensions: { public: true },
1783
+ * astNode: formatArg,
1784
+ * },
1785
+ * },
1786
+ * resolve: (user, { format }) => {
1787
+ * return format === 'long' ? user.fullName : user.name;
1788
+ * },
1789
+ * deprecationReason: 'Use displayName.',
1790
+ * extensions: { cacheSeconds: 60 },
1791
+ * astNode: nameField,
1792
+ * },
1793
+ * },
1794
+ * isTypeOf: (value) => {
1795
+ * return typeof value === 'object' && value != null && 'id' in value;
1796
+ * },
1797
+ * extensions: { entity: 'User' },
1798
+ * astNode: definition,
1799
+ * extensionASTNodes: [ document.definitions[1] ],
1800
+ * });
1801
+ *
1802
+ * User.name; // => 'User'
1803
+ * User.getInterfaces(); // => [Node]
1804
+ * Object.keys(User.getFields()); // => ['id', 'name']
1805
+ * User.getFields().name.args[0].defaultValue; // => 'short'
1806
+ * User.extensions; // => { entity: 'User' }
1807
+ * ```
1808
+ * @example
1809
+ * ```ts
1810
+ * // This variant configures a subscription field with subscribe and resolve functions.
1811
+ * import { GraphQLObjectType, GraphQLString } from 'graphql/type';
1812
+ *
1813
+ * const Subscription = new GraphQLObjectType({
1814
+ * name: 'Subscription',
1815
+ * fields: {
1816
+ * greeting: {
1817
+ * type: GraphQLString,
1818
+ * subscribe: async function* () {
1819
+ * yield { greeting: 'Hello!' };
1820
+ * },
1821
+ * resolve: (event) => {
1822
+ * return event.greeting;
1823
+ * },
1824
+ * },
1825
+ * },
1826
+ * });
1827
+ *
1828
+ * typeof Subscription.getFields().greeting.subscribe; // => 'function'
1829
+ * ```
1830
+ */
444
1831
  constructor(config: Readonly<GraphQLObjectTypeConfig<TSource, TContext>>);
1832
+ /**
1833
+ * Returns the value used by `Object.prototype.toString`.
1834
+ * @returns The built-in string tag for this object.
1835
+ */
445
1836
  get [Symbol.toStringTag](): string;
1837
+ /**
1838
+ * Returns the fields defined by this type.
1839
+ * @returns The fields keyed by field name.
1840
+ * @example
1841
+ * ```ts
1842
+ * import { buildSchema } from 'graphql/utilities';
1843
+ * import { assertObjectType } from 'graphql/type';
1844
+ *
1845
+ * const schema = buildSchema(`
1846
+ * type User {
1847
+ * id: ID!
1848
+ * name: String
1849
+ * }
1850
+ *
1851
+ * type Query {
1852
+ * viewer: User
1853
+ * }
1854
+ * `);
1855
+ *
1856
+ * const User = assertObjectType(schema.getType('User'));
1857
+ * const fields = User.getFields();
1858
+ *
1859
+ * Object.keys(fields); // => ['id', 'name']
1860
+ * String(fields.id.type); // => 'ID!'
1861
+ * ```
1862
+ */
446
1863
  getFields(): GraphQLFieldMap<TSource, TContext>;
1864
+ /**
1865
+ * Returns the interfaces implemented by this type.
1866
+ * @returns The implemented interfaces.
1867
+ * @example
1868
+ * ```ts
1869
+ * import { buildSchema } from 'graphql/utilities';
1870
+ * import { assertObjectType } from 'graphql/type';
1871
+ *
1872
+ * const schema = buildSchema(`
1873
+ * interface Node {
1874
+ * id: ID!
1875
+ * }
1876
+ *
1877
+ * type User implements Node {
1878
+ * id: ID!
1879
+ * }
1880
+ *
1881
+ * type Query {
1882
+ * viewer: User
1883
+ * }
1884
+ * `);
1885
+ *
1886
+ * const User = assertObjectType(schema.getType('User'));
1887
+ *
1888
+ * User.getInterfaces().map((type) => type.name); // => ['Node']
1889
+ * ```
1890
+ */
447
1891
  getInterfaces(): ReadonlyArray<GraphQLInterfaceType>;
1892
+ /**
1893
+ * Returns a normalized configuration object for this object.
1894
+ * @returns A configuration object that can be used to recreate this object.
1895
+ * @example
1896
+ * ```ts
1897
+ * import { GraphQLObjectType, GraphQLString } from 'graphql/type';
1898
+ *
1899
+ * const User = new GraphQLObjectType({
1900
+ * name: 'User',
1901
+ * fields: {
1902
+ * name: { type: GraphQLString },
1903
+ * },
1904
+ * });
1905
+ *
1906
+ * const config = User.toConfig();
1907
+ * const UserCopy = new GraphQLObjectType(config);
1908
+ *
1909
+ * config.fields.name.type; // => GraphQLString
1910
+ * UserCopy.getFields().name.type; // => GraphQLString
1911
+ * ```
1912
+ */
448
1913
  toConfig(): GraphQLObjectTypeNormalizedConfig<TSource, TContext>;
1914
+ /**
1915
+ * Returns the schema coordinate identifying this object type.
1916
+ * @returns The schema coordinate for this object type.
1917
+ * @example
1918
+ * ```ts
1919
+ * import { buildSchema } from 'graphql/utilities';
1920
+ * import { assertObjectType } from 'graphql/type';
1921
+ *
1922
+ * const schema = buildSchema(`
1923
+ * type User {
1924
+ * name: String
1925
+ * }
1926
+ *
1927
+ * type Query {
1928
+ * viewer: User
1929
+ * }
1930
+ * `);
1931
+ *
1932
+ * const User = assertObjectType(schema.getType('User'));
1933
+ *
1934
+ * User.toString(); // => 'User'
1935
+ * ```
1936
+ */
449
1937
  toString(): string;
1938
+ /**
1939
+ * Returns the JSON representation used when this object is serialized.
1940
+ * @returns The JSON-serializable representation.
1941
+ * @example
1942
+ * ```ts
1943
+ * import { GraphQLObjectType, GraphQLString } from 'graphql/type';
1944
+ *
1945
+ * const User = new GraphQLObjectType({
1946
+ * name: 'User',
1947
+ * fields: { name: { type: GraphQLString } },
1948
+ * });
1949
+ *
1950
+ * User.toJSON(); // => 'User'
1951
+ * JSON.stringify({ type: User }); // => '{"type":"User"}'
1952
+ * ```
1953
+ */
450
1954
  toJSON(): string;
451
1955
  }
1956
+ /** @internal */
452
1957
  export declare function defineArguments(
453
1958
  config: GraphQLFieldConfigArgumentMap,
454
1959
  ): ReadonlyArray<GraphQLArgument>;
455
- /**
456
- * @internal
457
- */
1960
+ /** @internal */
458
1961
  export declare function argsToArgsConfig(
459
1962
  args: ReadonlyArray<GraphQLArgument>,
460
1963
  ): GraphQLFieldConfigArgumentMap;
1964
+ /**
1965
+ * Configuration used to construct a GraphQLObjectType.
1966
+ * @typeParam TSource - Source object type passed to resolvers.
1967
+ * @typeParam TContext - Context object type passed to resolvers.
1968
+ */
461
1969
  export interface GraphQLObjectTypeConfig<TSource, TContext> {
1970
+ /** The GraphQL name for this schema element. */
462
1971
  name: string;
1972
+ /** Human-readable description for this schema element, if provided. */
463
1973
  description?: Maybe<string>;
1974
+ /** Interfaces implemented by this object or interface type. */
464
1975
  interfaces?: ThunkReadonlyArray<GraphQLInterfaceType>;
1976
+ /** Fields declared by this object, interface, input object, or literal. */
465
1977
  fields: ThunkObjMap<GraphQLFieldConfig<TSource, TContext>>;
1978
+ /** Predicate used to determine whether a runtime value belongs to this object type. */
466
1979
  isTypeOf?: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
1980
+ /** Extension fields to include in the formatted result. */
467
1981
  extensions?: Maybe<Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>>;
1982
+ /** AST node from which this schema element was built, if available. */
468
1983
  astNode?: Maybe<ObjectTypeDefinitionNode>;
1984
+ /** AST extension nodes applied to this schema element. */
469
1985
  extensionASTNodes?: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
470
1986
  }
471
1987
  interface GraphQLObjectTypeNormalizedConfig<TSource, TContext>
@@ -475,17 +1991,34 @@ interface GraphQLObjectTypeNormalizedConfig<TSource, TContext>
475
1991
  extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>;
476
1992
  extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode>;
477
1993
  }
1994
+ /**
1995
+ * Resolves the concrete object type for an abstract GraphQL type.
1996
+ * @typeParam TSource - Source object type passed to resolvers.
1997
+ * @typeParam TContext - Context object type passed to resolvers.
1998
+ */
478
1999
  export declare type GraphQLTypeResolver<TSource, TContext> = (
479
2000
  value: TSource,
480
2001
  context: TContext,
481
2002
  info: GraphQLResolveInfo,
482
2003
  abstractType: GraphQLAbstractType,
483
2004
  ) => PromiseOrValue<string | undefined>;
2005
+ /**
2006
+ * Checks whether a runtime value belongs to a GraphQL object type.
2007
+ * @typeParam TSource - Source object type tested against this object type.
2008
+ * @typeParam TContext - Context object type passed to resolvers.
2009
+ */
484
2010
  export declare type GraphQLIsTypeOfFn<TSource, TContext> = (
485
2011
  source: TSource,
486
2012
  context: TContext,
487
2013
  info: GraphQLResolveInfo,
488
2014
  ) => PromiseOrValue<boolean>;
2015
+ /**
2016
+ * Resolves the runtime value for a GraphQL field.
2017
+ * @typeParam TSource - Source object type passed to resolvers.
2018
+ * @typeParam TContext - Context object type passed to resolvers.
2019
+ * @typeParam TArgs - Argument object type passed to resolvers.
2020
+ * @typeParam TResult - Result value type.
2021
+ */
489
2022
  export declare type GraphQLFieldResolver<
490
2023
  TSource,
491
2024
  TContext,
@@ -497,52 +2030,78 @@ export declare type GraphQLFieldResolver<
497
2030
  context: TContext,
498
2031
  info: GraphQLResolveInfo,
499
2032
  ) => TResult;
2033
+ /** Information about the currently executing GraphQL field. */
500
2034
  export interface GraphQLResolveInfo {
2035
+ /** The field name referenced by this schema coordinate. */
501
2036
  readonly fieldName: string;
2037
+ /** AST field nodes that contributed to the current field execution. */
502
2038
  readonly fieldNodes: ReadonlyArray<FieldNode>;
2039
+ /** GraphQL output type declared for the current field. */
503
2040
  readonly returnType: GraphQLOutputType;
2041
+ /** Object type that owns the current field. */
504
2042
  readonly parentType: GraphQLObjectType;
2043
+ /** Response path where this error occurred during execution. */
505
2044
  readonly path: Path;
2045
+ /** The schema used for validation or execution. */
506
2046
  readonly schema: GraphQLSchema;
2047
+ /** Fragment definitions in the operation document keyed by fragment name. */
507
2048
  readonly fragments: ObjMap<FragmentDefinitionNode>;
2049
+ /** Initial root value passed to the operation. */
508
2050
  readonly rootValue: unknown;
2051
+ /** The operation selected for execution. */
509
2052
  readonly operation: OperationDefinitionNode;
2053
+ /** Runtime variable values keyed by variable name. */
510
2054
  readonly variableValues: {
511
2055
  [variable: string]: unknown;
512
2056
  };
513
2057
  }
514
2058
  /**
515
2059
  * Custom extensions
516
- *
517
2060
  * @remarks
518
2061
  * Use a unique identifier name for your extension, for example the name of
519
2062
  * your library or project. Do not use a shortened identifier as this increases
520
2063
  * the risk of conflicts. We recommend you add at most one extension field,
521
2064
  * an object which can contain all the values you need.
522
- *
523
2065
  * We've provided these template arguments because this is an open type and
524
2066
  * you may find them useful.
2067
+ * @typeParam _TSource - Reserved source type parameter for extension typing.
2068
+ * @typeParam _TContext - Reserved context type parameter for extension typing.
2069
+ * @typeParam _TArgs - Reserved argument type parameter for extension typing.
525
2070
  */
526
2071
  export interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> {
527
2072
  [attributeName: string]: unknown;
528
2073
  }
2074
+ /**
2075
+ * Configuration used to define a GraphQL field.
2076
+ * @typeParam TSource - Source object type passed to resolvers.
2077
+ * @typeParam TContext - Context object type passed to resolvers.
2078
+ * @typeParam TArgs - Argument object type passed to resolvers.
2079
+ */
529
2080
  export interface GraphQLFieldConfig<TSource, TContext, TArgs = any> {
2081
+ /** Human-readable description for this schema element, if provided. */
530
2082
  description?: Maybe<string>;
2083
+ /** The GraphQL type reference or runtime type for this element. */
531
2084
  type: GraphQLOutputType;
2085
+ /** Arguments accepted by this field or directive. */
532
2086
  args?: GraphQLFieldConfigArgumentMap;
2087
+ /** Resolver function used to produce this field value. */
533
2088
  resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
2089
+ /** Resolver function used to create a subscription event stream for this field. */
534
2090
  subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
2091
+ /** Reason this element is deprecated, if one was provided. */
535
2092
  deprecationReason?: Maybe<string>;
2093
+ /** Extension fields to include in the formatted result. */
536
2094
  extensions?: Maybe<
537
2095
  Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>
538
2096
  >;
2097
+ /** AST node from which this schema element was built, if available. */
539
2098
  astNode?: Maybe<FieldDefinitionNode>;
540
2099
  }
2100
+ /** A map of argument names to argument configuration objects. */
541
2101
  export declare type GraphQLFieldConfigArgumentMap =
542
2102
  ObjMap<GraphQLArgumentConfig>;
543
2103
  /**
544
2104
  * Custom extensions
545
- *
546
2105
  * @remarks
547
2106
  * Use a unique identifier name for your extension, for example the name of
548
2107
  * your library or project. Do not use a shortened identifier as this increases
@@ -552,44 +2111,109 @@ export declare type GraphQLFieldConfigArgumentMap =
552
2111
  export interface GraphQLArgumentExtensions {
553
2112
  [attributeName: string]: unknown;
554
2113
  }
2114
+ /** Configuration used to define a GraphQL argument. */
555
2115
  export interface GraphQLArgumentConfig {
2116
+ /** Human-readable description for this schema element, if provided. */
556
2117
  description?: Maybe<string>;
2118
+ /** The GraphQL type reference or runtime type for this element. */
557
2119
  type: GraphQLInputType;
2120
+ /** Default value used when no explicit value is supplied. */
558
2121
  defaultValue?: unknown;
2122
+ /** Reason this element is deprecated, if one was provided. */
559
2123
  deprecationReason?: Maybe<string>;
2124
+ /** Extension fields to include in the formatted result. */
560
2125
  extensions?: Maybe<Readonly<GraphQLArgumentExtensions>>;
2126
+ /** AST node from which this schema element was built, if available. */
561
2127
  astNode?: Maybe<InputValueDefinitionNode>;
562
2128
  }
2129
+ /**
2130
+ * A map of field names to field configuration objects.
2131
+ * @typeParam TSource - Source object type passed to resolvers.
2132
+ * @typeParam TContext - Context object type passed to resolvers.
2133
+ */
563
2134
  export declare type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<
564
2135
  GraphQLFieldConfig<TSource, TContext>
565
2136
  >;
2137
+ /**
2138
+ * A resolved GraphQL field definition.
2139
+ * @typeParam TSource - Source object type passed to resolvers.
2140
+ * @typeParam TContext - Context object type passed to resolvers.
2141
+ * @typeParam TArgs - Argument object type passed to resolvers.
2142
+ */
566
2143
  export interface GraphQLField<TSource, TContext, TArgs = any> {
2144
+ /** The GraphQL name for this schema element. */
567
2145
  name: string;
2146
+ /** Human-readable description for this schema element, if provided. */
568
2147
  description: Maybe<string>;
2148
+ /** The GraphQL type reference or runtime type for this element. */
569
2149
  type: GraphQLOutputType;
2150
+ /** Arguments accepted by this field or directive. */
570
2151
  args: ReadonlyArray<GraphQLArgument>;
2152
+ /** Resolver function used to produce this field value. */
571
2153
  resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
2154
+ /** Resolver function used to create a subscription event stream for this field. */
572
2155
  subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
2156
+ /** Reason this element is deprecated, if one was provided. */
573
2157
  deprecationReason: Maybe<string>;
2158
+ /** Extension fields to include in the formatted result. */
574
2159
  extensions: Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>;
2160
+ /** AST node from which this schema element was built, if available. */
575
2161
  astNode: Maybe<FieldDefinitionNode>;
576
2162
  }
2163
+ /** A resolved GraphQL argument definition. */
577
2164
  export interface GraphQLArgument {
2165
+ /** The GraphQL name for this schema element. */
578
2166
  name: string;
2167
+ /** Human-readable description for this schema element, if provided. */
579
2168
  description: Maybe<string>;
2169
+ /** The GraphQL type reference or runtime type for this element. */
580
2170
  type: GraphQLInputType;
2171
+ /** Default value used when no explicit value is supplied. */
581
2172
  defaultValue: unknown;
2173
+ /** Reason this element is deprecated, if one was provided. */
582
2174
  deprecationReason: Maybe<string>;
2175
+ /** Extension fields to include in the formatted result. */
583
2176
  extensions: Readonly<GraphQLArgumentExtensions>;
2177
+ /** AST node from which this schema element was built, if available. */
584
2178
  astNode: Maybe<InputValueDefinitionNode>;
585
2179
  }
2180
+ /**
2181
+ * Returns true when the argument is non-null and has no default value.
2182
+ * @param arg - The argument definition to inspect.
2183
+ * @returns True when the argument is non-null and has no default value.
2184
+ * @example
2185
+ * ```ts
2186
+ * import {
2187
+ * GraphQLInt,
2188
+ * GraphQLNonNull,
2189
+ * GraphQLString,
2190
+ * isRequiredArgument,
2191
+ * } from 'graphql/type';
2192
+ *
2193
+ * const requiredArgument = { name: 'id', type: new GraphQLNonNull(GraphQLInt) };
2194
+ * const optionalArgument = { name: 'name', type: GraphQLString };
2195
+ * const argumentWithDefault = {
2196
+ * name: 'limit',
2197
+ * type: new GraphQLNonNull(GraphQLInt),
2198
+ * defaultValue: 10,
2199
+ * };
2200
+ *
2201
+ * isRequiredArgument(requiredArgument); // => true
2202
+ * isRequiredArgument(optionalArgument); // => false
2203
+ * isRequiredArgument(argumentWithDefault); // => false
2204
+ * ```
2205
+ */
586
2206
  export declare function isRequiredArgument(arg: GraphQLArgument): boolean;
2207
+ /**
2208
+ * A map of field names to resolved field definitions.
2209
+ * @typeParam TSource - Source object type passed to resolvers.
2210
+ * @typeParam TContext - Context object type passed to resolvers.
2211
+ */
587
2212
  export declare type GraphQLFieldMap<TSource, TContext> = ObjMap<
588
2213
  GraphQLField<TSource, TContext>
589
2214
  >;
590
2215
  /**
591
2216
  * Custom extensions
592
- *
593
2217
  * @remarks
594
2218
  * Use a unique identifier name for your extension, for example the name of
595
2219
  * your library or project. Do not use a shortened identifier as this increases
@@ -606,9 +2230,7 @@ export interface GraphQLInterfaceTypeExtensions {
606
2230
  * is used to describe what types are possible, what fields are in common across
607
2231
  * all types, as well as a function to determine which type is actually used
608
2232
  * when the field is resolved.
609
- *
610
- * Example:
611
- *
2233
+ * @example
612
2234
  * ```ts
613
2235
  * const EntityType = new GraphQLInterfaceType({
614
2236
  * name: 'Entity',
@@ -619,26 +2241,223 @@ export interface GraphQLInterfaceTypeExtensions {
619
2241
  * ```
620
2242
  */
621
2243
  export declare class GraphQLInterfaceType {
2244
+ /** The GraphQL name for this schema element. */
622
2245
  name: string;
2246
+ /** Human-readable description for this schema element, if provided. */
623
2247
  description: Maybe<string>;
2248
+ /** Function that resolves the concrete object type for this abstract type. */
624
2249
  resolveType: Maybe<GraphQLTypeResolver<any, any>>;
2250
+ /** Extension fields to include in the formatted result. */
625
2251
  extensions: Readonly<GraphQLInterfaceTypeExtensions>;
2252
+ /** AST node from which this schema element was built, if available. */
626
2253
  astNode: Maybe<InterfaceTypeDefinitionNode>;
2254
+ /** AST extension nodes applied to this schema element. */
627
2255
  extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode>;
628
2256
  private _fields;
629
2257
  private _interfaces;
2258
+ /**
2259
+ * Creates a GraphQLInterfaceType instance.
2260
+ * @param config - Configuration describing this object.
2261
+ * @example
2262
+ * ```ts
2263
+ * import { parse } from 'graphql/language';
2264
+ * import { GraphQLID, GraphQLInterfaceType, GraphQLNonNull } from 'graphql/type';
2265
+ *
2266
+ * const document = parse(`
2267
+ * interface Node {
2268
+ * id: ID!
2269
+ * }
2270
+ *
2271
+ * interface Resource implements Node {
2272
+ * id: ID!
2273
+ * }
2274
+ *
2275
+ * extend interface Resource {
2276
+ * url: String
2277
+ * }
2278
+ * `);
2279
+ *
2280
+ * const Node = new GraphQLInterfaceType({
2281
+ * name: 'Node',
2282
+ * fields: {
2283
+ * id: { type: new GraphQLNonNull(GraphQLID) },
2284
+ * },
2285
+ * });
2286
+ *
2287
+ * const Resource = new GraphQLInterfaceType({
2288
+ * name: 'Resource',
2289
+ * description: 'An addressable resource.',
2290
+ * interfaces: [Node],
2291
+ * fields: {
2292
+ * id: { type: new GraphQLNonNull(GraphQLID) },
2293
+ * },
2294
+ * resolveType: (value) => {
2295
+ * return typeof value === 'object' && value != null && 'url' in value
2296
+ * ? 'WebPage'
2297
+ * : null;
2298
+ * },
2299
+ * extensions: { abstract: true },
2300
+ * astNode: document.definitions[1],
2301
+ * extensionASTNodes: [ document.definitions[2] ],
2302
+ * });
2303
+ *
2304
+ * Resource.name; // => 'Resource'
2305
+ * Resource.getInterfaces(); // => [Node]
2306
+ * Object.keys(Resource.getFields()); // => ['id']
2307
+ * Resource.extensions; // => { abstract: true }
2308
+ * ```
2309
+ */
630
2310
  constructor(config: Readonly<GraphQLInterfaceTypeConfig<any, any>>);
2311
+ /**
2312
+ * Returns the value used by `Object.prototype.toString`.
2313
+ * @returns The built-in string tag for this object.
2314
+ */
631
2315
  get [Symbol.toStringTag](): string;
2316
+ /**
2317
+ * Returns the fields defined by this type.
2318
+ * @returns The fields keyed by field name.
2319
+ * @example
2320
+ * ```ts
2321
+ * import { buildSchema } from 'graphql/utilities';
2322
+ * import { assertInterfaceType } from 'graphql/type';
2323
+ *
2324
+ * const schema = buildSchema(`
2325
+ * interface Node {
2326
+ * id: ID!
2327
+ * }
2328
+ *
2329
+ * type User implements Node {
2330
+ * id: ID!
2331
+ * }
2332
+ *
2333
+ * type Query {
2334
+ * node: Node
2335
+ * }
2336
+ * `);
2337
+ *
2338
+ * const Node = assertInterfaceType(schema.getType('Node'));
2339
+ * const fields = Node.getFields();
2340
+ *
2341
+ * Object.keys(fields); // => ['id']
2342
+ * String(fields.id.type); // => 'ID!'
2343
+ * ```
2344
+ */
632
2345
  getFields(): GraphQLFieldMap<any, any>;
2346
+ /**
2347
+ * Returns the interfaces implemented by this type.
2348
+ * @returns The implemented interfaces.
2349
+ * @example
2350
+ * ```ts
2351
+ * import { buildSchema } from 'graphql/utilities';
2352
+ * import { assertInterfaceType } from 'graphql/type';
2353
+ *
2354
+ * const schema = buildSchema(`
2355
+ * interface Resource {
2356
+ * url: String!
2357
+ * }
2358
+ *
2359
+ * interface Image implements Resource {
2360
+ * url: String!
2361
+ * width: Int
2362
+ * }
2363
+ *
2364
+ * type Photo implements Resource & Image {
2365
+ * url: String!
2366
+ * width: Int
2367
+ * }
2368
+ *
2369
+ * type Query {
2370
+ * image: Image
2371
+ * }
2372
+ * `);
2373
+ *
2374
+ * const Image = assertInterfaceType(schema.getType('Image'));
2375
+ *
2376
+ * Image.getInterfaces().map((type) => type.name); // => ['Resource']
2377
+ * ```
2378
+ */
633
2379
  getInterfaces(): ReadonlyArray<GraphQLInterfaceType>;
2380
+ /**
2381
+ * Returns a normalized configuration object for this object.
2382
+ * @returns A configuration object that can be used to recreate this object.
2383
+ * @example
2384
+ * ```ts
2385
+ * import { GraphQLID, GraphQLInterfaceType, GraphQLNonNull } from 'graphql/type';
2386
+ *
2387
+ * const Node = new GraphQLInterfaceType({
2388
+ * name: 'Node',
2389
+ * fields: {
2390
+ * id: { type: new GraphQLNonNull(GraphQLID) },
2391
+ * },
2392
+ * });
2393
+ *
2394
+ * const config = Node.toConfig();
2395
+ * const NodeCopy = new GraphQLInterfaceType(config);
2396
+ *
2397
+ * String(config.fields.id.type); // => 'ID!'
2398
+ * String(NodeCopy.getFields().id.type); // => 'ID!'
2399
+ * ```
2400
+ */
634
2401
  toConfig(): GraphQLInterfaceTypeNormalizedConfig;
2402
+ /**
2403
+ * Returns the schema coordinate identifying this interface type.
2404
+ * @returns The schema coordinate for this interface type.
2405
+ * @example
2406
+ * ```ts
2407
+ * import { buildSchema } from 'graphql/utilities';
2408
+ * import { assertInterfaceType } from 'graphql/type';
2409
+ *
2410
+ * const schema = buildSchema(`
2411
+ * interface Node {
2412
+ * id: ID!
2413
+ * }
2414
+ *
2415
+ * type User implements Node {
2416
+ * id: ID!
2417
+ * }
2418
+ *
2419
+ * type Query {
2420
+ * node: Node
2421
+ * }
2422
+ * `);
2423
+ *
2424
+ * const Node = assertInterfaceType(schema.getType('Node'));
2425
+ *
2426
+ * Node.toString(); // => 'Node'
2427
+ * ```
2428
+ */
635
2429
  toString(): string;
2430
+ /**
2431
+ * Returns the JSON representation used when this object is serialized.
2432
+ * @returns The JSON-serializable representation.
2433
+ * @example
2434
+ * ```ts
2435
+ * import { GraphQLInterfaceType, GraphQLString } from 'graphql/type';
2436
+ *
2437
+ * const Named = new GraphQLInterfaceType({
2438
+ * name: 'Named',
2439
+ * fields: { name: { type: GraphQLString } },
2440
+ * });
2441
+ *
2442
+ * Named.toJSON(); // => 'Named'
2443
+ * JSON.stringify({ type: Named }); // => '{"type":"Named"}'
2444
+ * ```
2445
+ */
636
2446
  toJSON(): string;
637
2447
  }
2448
+ /**
2449
+ * Configuration used to construct a GraphQLInterfaceType.
2450
+ * @typeParam TSource - Source object type passed to resolvers.
2451
+ * @typeParam TContext - Context object type passed to resolvers.
2452
+ */
638
2453
  export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
2454
+ /** The GraphQL name for this schema element. */
639
2455
  name: string;
2456
+ /** Human-readable description for this schema element, if provided. */
640
2457
  description?: Maybe<string>;
2458
+ /** Interfaces implemented by this object or interface type. */
641
2459
  interfaces?: ThunkReadonlyArray<GraphQLInterfaceType>;
2460
+ /** Fields declared by this object, interface, input object, or literal. */
642
2461
  fields: ThunkObjMap<GraphQLFieldConfig<TSource, TContext>>;
643
2462
  /**
644
2463
  * Optionally provide a custom type resolver function. If one is not provided,
@@ -646,10 +2465,14 @@ export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
646
2465
  * Object type.
647
2466
  */
648
2467
  resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
2468
+ /** Extension fields to include in the formatted result. */
649
2469
  extensions?: Maybe<Readonly<GraphQLInterfaceTypeExtensions>>;
2470
+ /** AST node from which this schema element was built, if available. */
650
2471
  astNode?: Maybe<InterfaceTypeDefinitionNode>;
2472
+ /** AST extension nodes applied to this schema element. */
651
2473
  extensionASTNodes?: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
652
2474
  }
2475
+ /** @internal */
653
2476
  export interface GraphQLInterfaceTypeNormalizedConfig
654
2477
  extends GraphQLInterfaceTypeConfig<any, any> {
655
2478
  interfaces: ReadonlyArray<GraphQLInterfaceType>;
@@ -659,7 +2482,6 @@ export interface GraphQLInterfaceTypeNormalizedConfig
659
2482
  }
660
2483
  /**
661
2484
  * Custom extensions
662
- *
663
2485
  * @remarks
664
2486
  * Use a unique identifier name for your extension, for example the name of
665
2487
  * your library or project. Do not use a shortened identifier as this increases
@@ -675,14 +2497,12 @@ export interface GraphQLUnionTypeExtensions {
675
2497
  * When a field can return one of a heterogeneous set of types, a Union type
676
2498
  * is used to describe what types are possible as well as providing a function
677
2499
  * to determine which type is actually used when the field is resolved.
678
- *
679
- * Example:
680
- *
2500
+ * @example
681
2501
  * ```ts
682
2502
  * const PetType = new GraphQLUnionType({
683
2503
  * name: 'Pet',
684
- * types: [ DogType, CatType ],
685
- * resolveType(value) {
2504
+ * types: [DogType, CatType],
2505
+ * resolveType: (value) => {
686
2506
  * if (value instanceof Dog) {
687
2507
  * return DogType;
688
2508
  * }
@@ -694,23 +2514,183 @@ export interface GraphQLUnionTypeExtensions {
694
2514
  * ```
695
2515
  */
696
2516
  export declare class GraphQLUnionType {
2517
+ /** The GraphQL name for this schema element. */
697
2518
  name: string;
2519
+ /** Human-readable description for this schema element, if provided. */
698
2520
  description: Maybe<string>;
2521
+ /** Function that resolves the concrete object type for this abstract type. */
699
2522
  resolveType: Maybe<GraphQLTypeResolver<any, any>>;
2523
+ /** Extension fields to include in the formatted result. */
700
2524
  extensions: Readonly<GraphQLUnionTypeExtensions>;
2525
+ /** AST node from which this schema element was built, if available. */
701
2526
  astNode: Maybe<UnionTypeDefinitionNode>;
2527
+ /** AST extension nodes applied to this schema element. */
702
2528
  extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>;
703
2529
  private _types;
2530
+ /**
2531
+ * Creates a GraphQLUnionType instance.
2532
+ * @param config - Configuration describing this object.
2533
+ * @example
2534
+ * ```ts
2535
+ * import { parse } from 'graphql/language';
2536
+ * import { GraphQLObjectType, GraphQLString, GraphQLUnionType } from 'graphql/type';
2537
+ *
2538
+ * const document = parse(`
2539
+ * union Media = Photo | Video
2540
+ *
2541
+ * extend union Media = Audio
2542
+ * `);
2543
+ *
2544
+ * const Photo = new GraphQLObjectType({
2545
+ * name: 'Photo',
2546
+ * fields: { url: { type: GraphQLString } },
2547
+ * });
2548
+ * const Video = new GraphQLObjectType({
2549
+ * name: 'Video',
2550
+ * fields: { url: { type: GraphQLString } },
2551
+ * });
2552
+ *
2553
+ * const Media = new GraphQLUnionType({
2554
+ * name: 'Media',
2555
+ * description: 'Media that can appear in a search result.',
2556
+ * types: [Photo, Video],
2557
+ * resolveType: (value) => {
2558
+ * return typeof value === 'object' && value != null && 'duration' in value
2559
+ * ? 'Video'
2560
+ * : 'Photo';
2561
+ * },
2562
+ * extensions: { searchable: true },
2563
+ * astNode: document.definitions[0],
2564
+ * extensionASTNodes: [ document.definitions[1] ],
2565
+ * });
2566
+ *
2567
+ * Media.description; // => 'Media that can appear in a search result.'
2568
+ * Media.getTypes().map((type) => type.name); // => ['Photo', 'Video']
2569
+ * Media.extensions; // => { searchable: true }
2570
+ * ```
2571
+ */
704
2572
  constructor(config: Readonly<GraphQLUnionTypeConfig<any, any>>);
2573
+ /**
2574
+ * Returns the value used by `Object.prototype.toString`.
2575
+ * @returns The built-in string tag for this object.
2576
+ */
705
2577
  get [Symbol.toStringTag](): string;
2578
+ /**
2579
+ * Returns the object types included in this union.
2580
+ * @returns The union member object types.
2581
+ * @example
2582
+ * ```ts
2583
+ * import { buildSchema } from 'graphql/utilities';
2584
+ * import { assertUnionType } from 'graphql/type';
2585
+ *
2586
+ * const schema = buildSchema(`
2587
+ * type Photo {
2588
+ * url: String!
2589
+ * }
2590
+ *
2591
+ * type Video {
2592
+ * url: String!
2593
+ * }
2594
+ *
2595
+ * union Media = Photo | Video
2596
+ *
2597
+ * type Query {
2598
+ * media: [Media]
2599
+ * }
2600
+ * `);
2601
+ *
2602
+ * const Media = assertUnionType(schema.getType('Media'));
2603
+ *
2604
+ * Media.getTypes().map((type) => type.name); // => ['Photo', 'Video']
2605
+ * ```
2606
+ */
706
2607
  getTypes(): ReadonlyArray<GraphQLObjectType>;
2608
+ /**
2609
+ * Returns a normalized configuration object for this object.
2610
+ * @returns A configuration object that can be used to recreate this object.
2611
+ * @example
2612
+ * ```ts
2613
+ * import { GraphQLObjectType, GraphQLString, GraphQLUnionType } from 'graphql/type';
2614
+ *
2615
+ * const Photo = new GraphQLObjectType({
2616
+ * name: 'Photo',
2617
+ * fields: { url: { type: GraphQLString } },
2618
+ * });
2619
+ * const Video = new GraphQLObjectType({
2620
+ * name: 'Video',
2621
+ * fields: { url: { type: GraphQLString } },
2622
+ * });
2623
+ * const Media = new GraphQLUnionType({
2624
+ * name: 'Media',
2625
+ * types: [Photo, Video],
2626
+ * });
2627
+ *
2628
+ * const config = Media.toConfig();
2629
+ * const MediaCopy = new GraphQLUnionType(config);
2630
+ *
2631
+ * MediaCopy.getTypes().map((type) => type.name); // => ['Photo', 'Video']
2632
+ * ```
2633
+ */
707
2634
  toConfig(): GraphQLUnionTypeNormalizedConfig;
2635
+ /**
2636
+ * Returns the schema coordinate identifying this union type.
2637
+ * @returns The schema coordinate for this union type.
2638
+ * @example
2639
+ * ```ts
2640
+ * import { buildSchema } from 'graphql/utilities';
2641
+ * import { assertUnionType } from 'graphql/type';
2642
+ *
2643
+ * const schema = buildSchema(`
2644
+ * type Photo {
2645
+ * url: String!
2646
+ * }
2647
+ *
2648
+ * union SearchResult = Photo
2649
+ *
2650
+ * type Query {
2651
+ * search: [SearchResult]
2652
+ * }
2653
+ * `);
2654
+ *
2655
+ * const SearchResult = assertUnionType(schema.getType('SearchResult'));
2656
+ *
2657
+ * SearchResult.toString(); // => 'SearchResult'
2658
+ * ```
2659
+ */
708
2660
  toString(): string;
2661
+ /**
2662
+ * Returns the JSON representation used when this object is serialized.
2663
+ * @returns The JSON-serializable representation.
2664
+ * @example
2665
+ * ```ts
2666
+ * import { GraphQLObjectType, GraphQLString, GraphQLUnionType } from 'graphql/type';
2667
+ *
2668
+ * const Photo = new GraphQLObjectType({
2669
+ * name: 'Photo',
2670
+ * fields: { url: { type: GraphQLString } },
2671
+ * });
2672
+ * const SearchResult = new GraphQLUnionType({
2673
+ * name: 'SearchResult',
2674
+ * types: [Photo],
2675
+ * });
2676
+ *
2677
+ * SearchResult.toJSON(); // => 'SearchResult'
2678
+ * JSON.stringify({ type: SearchResult }); // => '{"type":"SearchResult"}'
2679
+ * ```
2680
+ */
709
2681
  toJSON(): string;
710
2682
  }
2683
+ /**
2684
+ * Configuration used to construct a GraphQLUnionType.
2685
+ * @typeParam TSource - Source object type passed to resolvers.
2686
+ * @typeParam TContext - Context object type passed to resolvers.
2687
+ */
711
2688
  export interface GraphQLUnionTypeConfig<TSource, TContext> {
2689
+ /** The GraphQL name for this schema element. */
712
2690
  name: string;
2691
+ /** Human-readable description for this schema element, if provided. */
713
2692
  description?: Maybe<string>;
2693
+ /** Object types that belong to this union type. */
714
2694
  types: ThunkReadonlyArray<GraphQLObjectType>;
715
2695
  /**
716
2696
  * Optionally provide a custom type resolver function. If one is not provided,
@@ -718,8 +2698,11 @@ export interface GraphQLUnionTypeConfig<TSource, TContext> {
718
2698
  * Object type.
719
2699
  */
720
2700
  resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
2701
+ /** Extension fields to include in the formatted result. */
721
2702
  extensions?: Maybe<Readonly<GraphQLUnionTypeExtensions>>;
2703
+ /** AST node from which this schema element was built, if available. */
722
2704
  astNode?: Maybe<UnionTypeDefinitionNode>;
2705
+ /** AST extension nodes applied to this schema element. */
723
2706
  extensionASTNodes?: Maybe<ReadonlyArray<UnionTypeExtensionNode>>;
724
2707
  }
725
2708
  interface GraphQLUnionTypeNormalizedConfig
@@ -730,7 +2713,6 @@ interface GraphQLUnionTypeNormalizedConfig
730
2713
  }
731
2714
  /**
732
2715
  * Custom extensions
733
- *
734
2716
  * @remarks
735
2717
  * Use a unique identifier name for your extension, for example the name of
736
2718
  * your library or project. Do not use a shortened identifier as this increases
@@ -743,55 +2725,304 @@ export interface GraphQLEnumTypeExtensions {
743
2725
  /**
744
2726
  * Enum Type Definition
745
2727
  *
746
- * Some leaf values of requests and input values are Enums. GraphQL serializes
747
- * Enum values as strings, however internally Enums can be represented by any
748
- * kind of type, often integers.
749
- *
750
- * Example:
751
- *
2728
+ * Enum types define leaf values whose serialized form is one of a fixed set
2729
+ * of GraphQL enum names. Internally, enum values can map to any runtime value,
2730
+ * often integers.
2731
+ * @example
752
2732
  * ```ts
2733
+ * import { GraphQLEnumType } from 'graphql/type';
2734
+ *
753
2735
  * const RGBType = new GraphQLEnumType({
754
2736
  * name: 'RGB',
755
2737
  * values: {
756
2738
  * RED: { value: 0 },
757
2739
  * GREEN: { value: 1 },
758
- * BLUE: { value: 2 }
759
- * }
2740
+ * BLUE: { value: 2 },
2741
+ * },
760
2742
  * });
2743
+ *
2744
+ * RGBType.getValue('GREEN')?.value; // => 1
761
2745
  * ```
762
2746
  *
763
2747
  * Note: If a value is not provided in a definition, the name of the enum value
764
2748
  * will be used as its internal value.
765
2749
  */
766
2750
  export declare class GraphQLEnumType {
2751
+ /** The GraphQL name for this schema element. */
767
2752
  name: string;
2753
+ /** Human-readable description for this schema element, if provided. */
768
2754
  description: Maybe<string>;
2755
+ /** Extension fields to include in the formatted result. */
769
2756
  extensions: Readonly<GraphQLEnumTypeExtensions>;
2757
+ /** AST node from which this schema element was built, if available. */
770
2758
  astNode: Maybe<EnumTypeDefinitionNode>;
2759
+ /** AST extension nodes applied to this schema element. */
771
2760
  extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode>;
772
2761
  private _values;
773
2762
  private _valueLookup;
774
2763
  private _nameLookup;
2764
+ /**
2765
+ * Creates a GraphQLEnumType instance.
2766
+ * @param config - Configuration describing this object.
2767
+ * @example
2768
+ * ```ts
2769
+ * import { parse } from 'graphql/language';
2770
+ * import { GraphQLEnumType } from 'graphql/type';
2771
+ *
2772
+ * const document = parse(`
2773
+ * enum Episode {
2774
+ * NEW_HOPE
2775
+ * EMPIRE
2776
+ * JEDI
2777
+ * }
2778
+ *
2779
+ * extend enum Episode {
2780
+ * FORCE_AWAKENS
2781
+ * }
2782
+ * `);
2783
+ * const definition = document.definitions[0];
2784
+ *
2785
+ * const Episode = new GraphQLEnumType({
2786
+ * name: 'Episode',
2787
+ * description: 'A Star Wars film episode.',
2788
+ * values: {
2789
+ * NEW_HOPE: {
2790
+ * value: 4,
2791
+ * description: 'Released in 1977.',
2792
+ * extensions: { trilogy: 'original' },
2793
+ * astNode: definition.values[0],
2794
+ * },
2795
+ * EMPIRE: { value: 5, astNode: definition.values[1] },
2796
+ * JEDI: {
2797
+ * value: 6,
2798
+ * deprecationReason: 'Use RETURN_OF_THE_JEDI.',
2799
+ * astNode: definition.values[2],
2800
+ * },
2801
+ * },
2802
+ * extensions: { catalog: 'films' },
2803
+ * astNode: definition,
2804
+ * extensionASTNodes: [ document.definitions[1] ],
2805
+ * });
2806
+ *
2807
+ * Episode.description; // => 'A Star Wars film episode.'
2808
+ * Episode.serialize(5); // => 'EMPIRE'
2809
+ * Episode.parseValue('JEDI'); // => 6
2810
+ * Episode.getValue('JEDI').deprecationReason; // => 'Use RETURN_OF_THE_JEDI.'
2811
+ * Episode.extensions; // => { catalog: 'films' }
2812
+ * ```
2813
+ */
775
2814
  constructor(config: Readonly<GraphQLEnumTypeConfig>);
2815
+ /**
2816
+ * Returns the value used by `Object.prototype.toString`.
2817
+ * @returns The built-in string tag for this object.
2818
+ */
776
2819
  get [Symbol.toStringTag](): string;
2820
+ /**
2821
+ * Returns the values defined by this enum type.
2822
+ * @returns Enum value definitions in schema order.
2823
+ * @example
2824
+ * ```ts
2825
+ * import { buildSchema } from 'graphql/utilities';
2826
+ * import { assertEnumType } from 'graphql/type';
2827
+ *
2828
+ * const schema = buildSchema(`
2829
+ * enum Episode {
2830
+ * NEW_HOPE
2831
+ * EMPIRE
2832
+ * JEDI
2833
+ * }
2834
+ *
2835
+ * type Query {
2836
+ * episode: Episode
2837
+ * }
2838
+ * `);
2839
+ *
2840
+ * const Episode = assertEnumType(schema.getType('Episode'));
2841
+ *
2842
+ * Episode.getValues().map((value) => value.name); // => ['NEW_HOPE', 'EMPIRE', 'JEDI']
2843
+ * ```
2844
+ */
777
2845
  getValues(): ReadonlyArray<GraphQLEnumValue>;
2846
+ /**
2847
+ * Returns the enum value definition for a value name.
2848
+ * @param name - The GraphQL name to look up.
2849
+ * @returns The matching enum value definition, if it exists.
2850
+ * @example
2851
+ * ```ts
2852
+ * import { buildSchema } from 'graphql/utilities';
2853
+ * import { assertEnumType } from 'graphql/type';
2854
+ *
2855
+ * const schema = buildSchema(`
2856
+ * enum Episode {
2857
+ * NEW_HOPE
2858
+ * EMPIRE
2859
+ * }
2860
+ *
2861
+ * type Query {
2862
+ * episode: Episode
2863
+ * }
2864
+ * `);
2865
+ *
2866
+ * const Episode = assertEnumType(schema.getType('Episode'));
2867
+ *
2868
+ * Episode.getValue('EMPIRE')?.name; // => 'EMPIRE'
2869
+ * Episode.getValue('JEDI'); // => undefined
2870
+ * ```
2871
+ */
778
2872
  getValue(name: string): Maybe<GraphQLEnumValue>;
2873
+ /**
2874
+ * Serializes a runtime enum value as a GraphQL enum name.
2875
+ * @param outputValue - Runtime enum value to serialize.
2876
+ * @returns The GraphQL enum name for the runtime value.
2877
+ * @example
2878
+ * ```ts
2879
+ * import { GraphQLEnumType } from 'graphql/type';
2880
+ *
2881
+ * const RGB = new GraphQLEnumType({
2882
+ * name: 'RGB',
2883
+ * values: {
2884
+ * RED: { value: 0 },
2885
+ * GREEN: { value: 1 },
2886
+ * BLUE: { value: 2 },
2887
+ * },
2888
+ * });
2889
+ *
2890
+ * RGB.serialize(1); // => 'GREEN'
2891
+ * RGB.serialize(3); // throws an error
2892
+ * ```
2893
+ */
779
2894
  serialize(outputValue: unknown): Maybe<string>;
2895
+ /**
2896
+ * Parses a GraphQL enum name from variable input.
2897
+ * @param inputValue - Runtime input value to parse.
2898
+ * @returns The internal enum value represented by the input name.
2899
+ * @example
2900
+ * ```ts
2901
+ * import { GraphQLEnumType } from 'graphql/type';
2902
+ *
2903
+ * const RGB = new GraphQLEnumType({
2904
+ * name: 'RGB',
2905
+ * values: {
2906
+ * RED: { value: 0 },
2907
+ * GREEN: { value: 1 },
2908
+ * BLUE: { value: 2 },
2909
+ * },
2910
+ * });
2911
+ *
2912
+ * RGB.parseValue('BLUE'); // => 2
2913
+ * RGB.parseValue('PURPLE'); // throws an error
2914
+ * RGB.parseValue(2); // throws an error
2915
+ * ```
2916
+ */
780
2917
  parseValue(inputValue: unknown): Maybe<any>;
2918
+ /**
2919
+ * Parses a GraphQL enum name from an AST value literal.
2920
+ * @param valueNode - AST value literal to parse.
2921
+ * @param _variables - Runtime variable values; ignored because enum literals cannot contain variables.
2922
+ * @returns The internal enum value represented by the literal.
2923
+ * @example
2924
+ * ```ts
2925
+ * import { parseValue } from 'graphql/language';
2926
+ * import { GraphQLEnumType } from 'graphql/type';
2927
+ *
2928
+ * const RGB = new GraphQLEnumType({
2929
+ * name: 'RGB',
2930
+ * values: {
2931
+ * RED: { value: 0 },
2932
+ * GREEN: { value: 1 },
2933
+ * BLUE: { value: 2 },
2934
+ * },
2935
+ * });
2936
+ *
2937
+ * RGB.parseLiteral(parseValue('RED')); // => 0
2938
+ * RGB.parseLiteral(parseValue('"RED"')); // throws an error
2939
+ * ```
2940
+ */
781
2941
  parseLiteral(
782
2942
  valueNode: ValueNode,
783
2943
  _variables: Maybe<ObjMap<unknown>>,
784
2944
  ): Maybe<any>;
2945
+ /**
2946
+ * Returns a normalized configuration object for this object.
2947
+ * @returns A configuration object that can be used to recreate this object.
2948
+ * @example
2949
+ * ```ts
2950
+ * import { GraphQLEnumType } from 'graphql/type';
2951
+ *
2952
+ * const RGB = new GraphQLEnumType({
2953
+ * name: 'RGB',
2954
+ * values: {
2955
+ * RED: { value: 0 },
2956
+ * GREEN: { value: 1 },
2957
+ * BLUE: { value: 2 },
2958
+ * },
2959
+ * });
2960
+ *
2961
+ * const config = RGB.toConfig();
2962
+ * const RGBCopy = new GraphQLEnumType(config);
2963
+ *
2964
+ * config.values.GREEN.value; // => 1
2965
+ * RGBCopy.serialize(2); // => 'BLUE'
2966
+ * ```
2967
+ */
785
2968
  toConfig(): GraphQLEnumTypeNormalizedConfig;
2969
+ /**
2970
+ * Returns the schema coordinate identifying this enum type.
2971
+ * @returns The schema coordinate for this enum type.
2972
+ * @example
2973
+ * ```ts
2974
+ * import { buildSchema } from 'graphql/utilities';
2975
+ * import { assertEnumType } from 'graphql/type';
2976
+ *
2977
+ * const schema = buildSchema(`
2978
+ * enum Episode {
2979
+ * NEW_HOPE
2980
+ * }
2981
+ *
2982
+ * type Query {
2983
+ * episode: Episode
2984
+ * }
2985
+ * `);
2986
+ *
2987
+ * const Episode = assertEnumType(schema.getType('Episode'));
2988
+ *
2989
+ * Episode.toString(); // => 'Episode'
2990
+ * ```
2991
+ */
786
2992
  toString(): string;
2993
+ /**
2994
+ * Returns the JSON representation used when this object is serialized.
2995
+ * @returns The JSON-serializable representation.
2996
+ * @example
2997
+ * ```ts
2998
+ * import { GraphQLEnumType } from 'graphql/type';
2999
+ *
3000
+ * const Episode = new GraphQLEnumType({
3001
+ * name: 'Episode',
3002
+ * values: {
3003
+ * NEW_HOPE: {},
3004
+ * },
3005
+ * });
3006
+ *
3007
+ * Episode.toJSON(); // => 'Episode'
3008
+ * JSON.stringify({ type: Episode }); // => '{"type":"Episode"}'
3009
+ * ```
3010
+ */
787
3011
  toJSON(): string;
788
3012
  }
3013
+ /** Configuration used to construct a GraphQLEnumType. */
789
3014
  export interface GraphQLEnumTypeConfig {
3015
+ /** The GraphQL name for this schema element. */
790
3016
  name: string;
3017
+ /** Human-readable description for this schema element, if provided. */
791
3018
  description?: Maybe<string>;
3019
+ /** Values contained in this enum, list, or input-object definition. */
792
3020
  values: ThunkObjMap<GraphQLEnumValueConfig>;
3021
+ /** Extension fields to include in the formatted result. */
793
3022
  extensions?: Maybe<Readonly<GraphQLEnumTypeExtensions>>;
3023
+ /** AST node from which this schema element was built, if available. */
794
3024
  astNode?: Maybe<EnumTypeDefinitionNode>;
3025
+ /** AST extension nodes applied to this schema element. */
795
3026
  extensionASTNodes?: Maybe<ReadonlyArray<EnumTypeExtensionNode>>;
796
3027
  }
797
3028
  interface GraphQLEnumTypeNormalizedConfig extends GraphQLEnumTypeConfig {
@@ -799,10 +3030,10 @@ interface GraphQLEnumTypeNormalizedConfig extends GraphQLEnumTypeConfig {
799
3030
  extensions: Readonly<GraphQLEnumTypeExtensions>;
800
3031
  extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode>;
801
3032
  }
3033
+ /** A map of enum value names to enum value configuration objects. */
802
3034
  export declare type GraphQLEnumValueConfigMap = ObjMap<GraphQLEnumValueConfig>;
803
3035
  /**
804
3036
  * Custom extensions
805
- *
806
3037
  * @remarks
807
3038
  * Use a unique identifier name for your extension, for example the name of
808
3039
  * your library or project. Do not use a shortened identifier as this increases
@@ -812,24 +3043,36 @@ export declare type GraphQLEnumValueConfigMap = ObjMap<GraphQLEnumValueConfig>;
812
3043
  export interface GraphQLEnumValueExtensions {
813
3044
  [attributeName: string]: unknown;
814
3045
  }
3046
+ /** Configuration used to define a GraphQL enum value. */
815
3047
  export interface GraphQLEnumValueConfig {
3048
+ /** Human-readable description for this schema element, if provided. */
816
3049
  description?: Maybe<string>;
3050
+ /** Parsed value represented by this node. */
817
3051
  value?: any;
3052
+ /** Reason this element is deprecated, if one was provided. */
818
3053
  deprecationReason?: Maybe<string>;
3054
+ /** Extension fields to include in the formatted result. */
819
3055
  extensions?: Maybe<Readonly<GraphQLEnumValueExtensions>>;
3056
+ /** AST node from which this schema element was built, if available. */
820
3057
  astNode?: Maybe<EnumValueDefinitionNode>;
821
3058
  }
3059
+ /** A resolved GraphQL enum value definition. */
822
3060
  export interface GraphQLEnumValue {
3061
+ /** The GraphQL name for this schema element. */
823
3062
  name: string;
3063
+ /** Human-readable description for this schema element, if provided. */
824
3064
  description: Maybe<string>;
3065
+ /** Parsed value represented by this node. */
825
3066
  value: any;
3067
+ /** Reason this element is deprecated, if one was provided. */
826
3068
  deprecationReason: Maybe<string>;
3069
+ /** Extension fields to include in the formatted result. */
827
3070
  extensions: Readonly<GraphQLEnumValueExtensions>;
3071
+ /** AST node from which this schema element was built, if available. */
828
3072
  astNode: Maybe<EnumValueDefinitionNode>;
829
3073
  }
830
3074
  /**
831
3075
  * Custom extensions
832
- *
833
3076
  * @remarks
834
3077
  * Use a unique identifier name for your extension, for example the name of
835
3078
  * your library or project. Do not use a shortened identifier as this increases
@@ -846,9 +3089,7 @@ export interface GraphQLInputObjectTypeExtensions {
846
3089
  * supplied to a field argument.
847
3090
  *
848
3091
  * Using `NonNull` will ensure that a value must be provided by the query
849
- *
850
- * Example:
851
- *
3092
+ * @example
852
3093
  * ```ts
853
3094
  * const GeoPoint = new GraphQLInputObjectType({
854
3095
  * name: 'GeoPoint',
@@ -861,27 +3102,205 @@ export interface GraphQLInputObjectTypeExtensions {
861
3102
  * ```
862
3103
  */
863
3104
  export declare class GraphQLInputObjectType {
3105
+ /** The GraphQL name for this schema element. */
864
3106
  name: string;
3107
+ /** Human-readable description for this schema element, if provided. */
865
3108
  description: Maybe<string>;
3109
+ /** Extension fields to include in the formatted result. */
866
3110
  extensions: Readonly<GraphQLInputObjectTypeExtensions>;
3111
+ /** AST node from which this schema element was built, if available. */
867
3112
  astNode: Maybe<InputObjectTypeDefinitionNode>;
3113
+ /** AST extension nodes applied to this schema element. */
868
3114
  extensionASTNodes: ReadonlyArray<InputObjectTypeExtensionNode>;
3115
+ /** Whether this input object uses the experimental OneOf input object semantics. */
869
3116
  isOneOf: boolean;
870
3117
  private _fields;
3118
+ /**
3119
+ * Creates a GraphQLInputObjectType instance.
3120
+ * @param config - Configuration describing this object.
3121
+ * @example
3122
+ * ```ts
3123
+ * import { parse } from 'graphql/language';
3124
+ * import {
3125
+ * GraphQLID,
3126
+ * GraphQLInputObjectType,
3127
+ * GraphQLInt,
3128
+ * GraphQLNonNull,
3129
+ * GraphQLString,
3130
+ * } from 'graphql/type';
3131
+ *
3132
+ * const document = parse(`
3133
+ * input ReviewInput {
3134
+ * stars: Int!
3135
+ * commentary: String
3136
+ * }
3137
+ *
3138
+ * extend input ReviewInput {
3139
+ * body: String
3140
+ * }
3141
+ * `);
3142
+ * const definition = document.definitions[0];
3143
+ *
3144
+ * const ReviewInput = new GraphQLInputObjectType({
3145
+ * name: 'ReviewInput',
3146
+ * description: 'Input collected when reviewing a product.',
3147
+ * fields: {
3148
+ * stars: {
3149
+ * description: 'Star rating from one to five.',
3150
+ * type: new GraphQLNonNull(GraphQLInt),
3151
+ * extensions: { min: 1, max: 5 },
3152
+ * astNode: definition.fields[0],
3153
+ * },
3154
+ * commentary: {
3155
+ * type: GraphQLString,
3156
+ * defaultValue: '',
3157
+ * deprecationReason: 'Use body.',
3158
+ * astNode: definition.fields[1],
3159
+ * },
3160
+ * },
3161
+ * extensions: { form: 'review' },
3162
+ * astNode: definition,
3163
+ * extensionASTNodes: [ document.definitions[1] ],
3164
+ * isOneOf: false,
3165
+ * });
3166
+ * const SearchBy = new GraphQLInputObjectType({
3167
+ * name: 'SearchBy',
3168
+ * fields: {
3169
+ * id: { type: GraphQLID },
3170
+ * slug: { type: GraphQLString },
3171
+ * },
3172
+ * isOneOf: true,
3173
+ * });
3174
+ *
3175
+ * const fields = ReviewInput.getFields();
3176
+ *
3177
+ * ReviewInput.description; // => 'Input collected when reviewing a product.'
3178
+ * String(fields.stars.type); // => 'Int!'
3179
+ * fields.stars.extensions; // => { min: 1, max: 5 }
3180
+ * fields.commentary.defaultValue; // => ''
3181
+ * fields.commentary.deprecationReason; // => 'Use body.'
3182
+ * ReviewInput.isOneOf; // => false
3183
+ * SearchBy.isOneOf; // => true
3184
+ * ```
3185
+ */
871
3186
  constructor(config: Readonly<GraphQLInputObjectTypeConfig>);
3187
+ /**
3188
+ * Returns the value used by `Object.prototype.toString`.
3189
+ * @returns The built-in string tag for this object.
3190
+ */
872
3191
  get [Symbol.toStringTag](): string;
3192
+ /**
3193
+ * Returns the fields defined by this type.
3194
+ * @returns The fields keyed by field name.
3195
+ * @example
3196
+ * ```ts
3197
+ * import { buildSchema } from 'graphql/utilities';
3198
+ * import { assertInputObjectType } from 'graphql/type';
3199
+ *
3200
+ * const schema = buildSchema(`
3201
+ * input ReviewInput {
3202
+ * stars: Int!
3203
+ * commentary: String = ""
3204
+ * }
3205
+ *
3206
+ * type Query {
3207
+ * reviews(filter: ReviewInput): [String]
3208
+ * }
3209
+ * `);
3210
+ *
3211
+ * const ReviewInput = assertInputObjectType(schema.getType('ReviewInput'));
3212
+ * const fields = ReviewInput.getFields();
3213
+ *
3214
+ * Object.keys(fields); // => ['stars', 'commentary']
3215
+ * fields.commentary.defaultValue; // => ''
3216
+ * ```
3217
+ */
873
3218
  getFields(): GraphQLInputFieldMap;
3219
+ /**
3220
+ * Returns a normalized configuration object for this object.
3221
+ * @returns A configuration object that can be used to recreate this object.
3222
+ * @example
3223
+ * ```ts
3224
+ * import {
3225
+ * GraphQLInputObjectType,
3226
+ * GraphQLInt,
3227
+ * GraphQLNonNull,
3228
+ * } from 'graphql/type';
3229
+ *
3230
+ * const ReviewInput = new GraphQLInputObjectType({
3231
+ * name: 'ReviewInput',
3232
+ * fields: {
3233
+ * stars: { type: new GraphQLNonNull(GraphQLInt) },
3234
+ * },
3235
+ * });
3236
+ *
3237
+ * const config = ReviewInput.toConfig();
3238
+ * const ReviewInputCopy = new GraphQLInputObjectType(config);
3239
+ *
3240
+ * String(config.fields.stars.type); // => 'Int!'
3241
+ * String(ReviewInputCopy.getFields().stars.type); // => 'Int!'
3242
+ * ```
3243
+ */
874
3244
  toConfig(): GraphQLInputObjectTypeNormalizedConfig;
3245
+ /**
3246
+ * Returns the schema coordinate identifying this input object type.
3247
+ * @returns The schema coordinate for this input object type.
3248
+ * @example
3249
+ * ```ts
3250
+ * import { buildSchema } from 'graphql/utilities';
3251
+ * import { assertInputObjectType } from 'graphql/type';
3252
+ *
3253
+ * const schema = buildSchema(`
3254
+ * input ReviewInput {
3255
+ * stars: Int!
3256
+ * }
3257
+ *
3258
+ * type Query {
3259
+ * reviews(filter: ReviewInput): [String]
3260
+ * }
3261
+ * `);
3262
+ *
3263
+ * const ReviewInput = assertInputObjectType(schema.getType('ReviewInput'));
3264
+ *
3265
+ * ReviewInput.toString(); // => 'ReviewInput'
3266
+ * ```
3267
+ */
875
3268
  toString(): string;
3269
+ /**
3270
+ * Returns the JSON representation used when this object is serialized.
3271
+ * @returns The JSON-serializable representation.
3272
+ * @example
3273
+ * ```ts
3274
+ * import { GraphQLInputObjectType, GraphQLString } from 'graphql/type';
3275
+ *
3276
+ * const ReviewInput = new GraphQLInputObjectType({
3277
+ * name: 'ReviewInput',
3278
+ * fields: {
3279
+ * commentary: { type: GraphQLString },
3280
+ * },
3281
+ * });
3282
+ *
3283
+ * ReviewInput.toJSON(); // => 'ReviewInput'
3284
+ * JSON.stringify({ type: ReviewInput }); // => '{"type":"ReviewInput"}'
3285
+ * ```
3286
+ */
876
3287
  toJSON(): string;
877
3288
  }
3289
+ /** Configuration used to construct a GraphQLInputObjectType. */
878
3290
  export interface GraphQLInputObjectTypeConfig {
3291
+ /** The GraphQL name for this schema element. */
879
3292
  name: string;
3293
+ /** Human-readable description for this schema element, if provided. */
880
3294
  description?: Maybe<string>;
3295
+ /** Fields declared by this object, interface, input object, or literal. */
881
3296
  fields: ThunkObjMap<GraphQLInputFieldConfig>;
3297
+ /** Extension fields to include in the formatted result. */
882
3298
  extensions?: Maybe<Readonly<GraphQLInputObjectTypeExtensions>>;
3299
+ /** AST node from which this schema element was built, if available. */
883
3300
  astNode?: Maybe<InputObjectTypeDefinitionNode>;
3301
+ /** AST extension nodes applied to this schema element. */
884
3302
  extensionASTNodes?: Maybe<ReadonlyArray<InputObjectTypeExtensionNode>>;
3303
+ /** Whether this input object uses the experimental OneOf input object semantics. */
885
3304
  isOneOf?: boolean;
886
3305
  }
887
3306
  interface GraphQLInputObjectTypeNormalizedConfig
@@ -892,7 +3311,6 @@ interface GraphQLInputObjectTypeNormalizedConfig
892
3311
  }
893
3312
  /**
894
3313
  * Custom extensions
895
- *
896
3314
  * @remarks
897
3315
  * Use a unique identifier name for your extension, for example the name of
898
3316
  * your library or project. Do not use a shortened identifier as this increases
@@ -902,25 +3320,68 @@ interface GraphQLInputObjectTypeNormalizedConfig
902
3320
  export interface GraphQLInputFieldExtensions {
903
3321
  [attributeName: string]: unknown;
904
3322
  }
3323
+ /** Configuration used to define a GraphQL input field. */
905
3324
  export interface GraphQLInputFieldConfig {
3325
+ /** Human-readable description for this schema element, if provided. */
906
3326
  description?: Maybe<string>;
3327
+ /** The GraphQL type reference or runtime type for this element. */
907
3328
  type: GraphQLInputType;
3329
+ /** Default value used when no explicit value is supplied. */
908
3330
  defaultValue?: unknown;
3331
+ /** Reason this element is deprecated, if one was provided. */
909
3332
  deprecationReason?: Maybe<string>;
3333
+ /** Extension fields to include in the formatted result. */
910
3334
  extensions?: Maybe<Readonly<GraphQLInputFieldExtensions>>;
3335
+ /** AST node from which this schema element was built, if available. */
911
3336
  astNode?: Maybe<InputValueDefinitionNode>;
912
3337
  }
3338
+ /** A map of input field names to input field configuration objects. */
913
3339
  export declare type GraphQLInputFieldConfigMap =
914
3340
  ObjMap<GraphQLInputFieldConfig>;
3341
+ /** A resolved GraphQL input field definition. */
915
3342
  export interface GraphQLInputField {
3343
+ /** The GraphQL name for this schema element. */
916
3344
  name: string;
3345
+ /** Human-readable description for this schema element, if provided. */
917
3346
  description: Maybe<string>;
3347
+ /** The GraphQL type reference or runtime type for this element. */
918
3348
  type: GraphQLInputType;
3349
+ /** Default value used when no explicit value is supplied. */
919
3350
  defaultValue: unknown;
3351
+ /** Reason this element is deprecated, if one was provided. */
920
3352
  deprecationReason: Maybe<string>;
3353
+ /** Extension fields to include in the formatted result. */
921
3354
  extensions: Readonly<GraphQLInputFieldExtensions>;
3355
+ /** AST node from which this schema element was built, if available. */
922
3356
  astNode: Maybe<InputValueDefinitionNode>;
923
3357
  }
3358
+ /**
3359
+ * Returns true when the input field is non-null and has no default value.
3360
+ * @param field - The input field definition to inspect.
3361
+ * @returns True when the input field is non-null and has no default value.
3362
+ * @example
3363
+ * ```ts
3364
+ * import {
3365
+ * GraphQLInt,
3366
+ * GraphQLNonNull,
3367
+ * GraphQLString,
3368
+ * isRequiredInputField,
3369
+ * } from 'graphql/type';
3370
+ *
3371
+ * const requiredField = { name: 'id', type: new GraphQLNonNull(GraphQLInt) };
3372
+ * const optionalField = { name: 'name', type: GraphQLString };
3373
+ * const fieldWithDefault = {
3374
+ * name: 'limit',
3375
+ * type: new GraphQLNonNull(GraphQLInt),
3376
+ * defaultValue: 10,
3377
+ * };
3378
+ *
3379
+ * isRequiredInputField(requiredField); // => true
3380
+ * isRequiredInputField(optionalField); // => false
3381
+ * isRequiredInputField(fieldWithDefault); // => false
3382
+ * ```
3383
+ */
924
3384
  export declare function isRequiredInputField(field: GraphQLInputField): boolean;
3385
+ /** A map of input field names to resolved input field definitions. */
925
3386
  export declare type GraphQLInputFieldMap = ObjMap<GraphQLInputField>;
926
3387
  export {};