index.js.flow 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. // @flow strict
  2. /**
  3. * GraphQL.js provides a reference implementation for the GraphQL specification
  4. * but is also a useful utility for operating on GraphQL files and building
  5. * sophisticated tools.
  6. *
  7. * This primary module exports a general purpose function for fulfilling all
  8. * steps of the GraphQL specification in a single operation, but also includes
  9. * utilities for every part of the GraphQL specification:
  10. *
  11. * - Parsing the GraphQL language.
  12. * - Building a GraphQL type schema.
  13. * - Validating a GraphQL request against a type schema.
  14. * - Executing a GraphQL request against a type schema.
  15. *
  16. * This also includes utility functions for operating on GraphQL types and
  17. * GraphQL documents to facilitate building tools.
  18. *
  19. * You may also import from each sub-directory directly. For example, the
  20. * following two import statements are equivalent:
  21. *
  22. * import { parse } from 'graphql';
  23. * import { parse } from 'graphql/language';
  24. */
  25. // The GraphQL.js version info.
  26. export { version, versionInfo } from './version';
  27. // The primary entry point into fulfilling a GraphQL request.
  28. export type { GraphQLArgs } from './graphql';
  29. export { graphql, graphqlSync } from './graphql';
  30. // Create and operate on GraphQL type definitions and schema.
  31. export {
  32. // Definitions
  33. GraphQLSchema,
  34. GraphQLDirective,
  35. GraphQLScalarType,
  36. GraphQLObjectType,
  37. GraphQLInterfaceType,
  38. GraphQLUnionType,
  39. GraphQLEnumType,
  40. GraphQLInputObjectType,
  41. GraphQLList,
  42. GraphQLNonNull,
  43. // Standard GraphQL Scalars
  44. specifiedScalarTypes,
  45. GraphQLInt,
  46. GraphQLFloat,
  47. GraphQLString,
  48. GraphQLBoolean,
  49. GraphQLID,
  50. // Built-in Directives defined by the Spec
  51. specifiedDirectives,
  52. GraphQLIncludeDirective,
  53. GraphQLSkipDirective,
  54. GraphQLDeprecatedDirective,
  55. GraphQLSpecifiedByDirective,
  56. // "Enum" of Type Kinds
  57. TypeKind,
  58. // Constant Deprecation Reason
  59. DEFAULT_DEPRECATION_REASON,
  60. // GraphQL Types for introspection.
  61. introspectionTypes,
  62. __Schema,
  63. __Directive,
  64. __DirectiveLocation,
  65. __Type,
  66. __Field,
  67. __InputValue,
  68. __EnumValue,
  69. __TypeKind,
  70. // Meta-field definitions.
  71. SchemaMetaFieldDef,
  72. TypeMetaFieldDef,
  73. TypeNameMetaFieldDef,
  74. // Predicates
  75. isSchema,
  76. isDirective,
  77. isType,
  78. isScalarType,
  79. isObjectType,
  80. isInterfaceType,
  81. isUnionType,
  82. isEnumType,
  83. isInputObjectType,
  84. isListType,
  85. isNonNullType,
  86. isInputType,
  87. isOutputType,
  88. isLeafType,
  89. isCompositeType,
  90. isAbstractType,
  91. isWrappingType,
  92. isNullableType,
  93. isNamedType,
  94. isRequiredArgument,
  95. isRequiredInputField,
  96. isSpecifiedScalarType,
  97. isIntrospectionType,
  98. isSpecifiedDirective,
  99. // Assertions
  100. assertSchema,
  101. assertDirective,
  102. assertType,
  103. assertScalarType,
  104. assertObjectType,
  105. assertInterfaceType,
  106. assertUnionType,
  107. assertEnumType,
  108. assertInputObjectType,
  109. assertListType,
  110. assertNonNullType,
  111. assertInputType,
  112. assertOutputType,
  113. assertLeafType,
  114. assertCompositeType,
  115. assertAbstractType,
  116. assertWrappingType,
  117. assertNullableType,
  118. assertNamedType,
  119. // Un-modifiers
  120. getNullableType,
  121. getNamedType,
  122. // Validate GraphQL schema.
  123. validateSchema,
  124. assertValidSchema,
  125. } from './type/index';
  126. export type {
  127. GraphQLType,
  128. GraphQLInputType,
  129. GraphQLOutputType,
  130. GraphQLLeafType,
  131. GraphQLCompositeType,
  132. GraphQLAbstractType,
  133. GraphQLWrappingType,
  134. GraphQLNullableType,
  135. GraphQLNamedType,
  136. Thunk,
  137. GraphQLSchemaConfig,
  138. GraphQLDirectiveConfig,
  139. GraphQLArgument,
  140. GraphQLArgumentConfig,
  141. GraphQLEnumTypeConfig,
  142. GraphQLEnumValue,
  143. GraphQLEnumValueConfig,
  144. GraphQLEnumValueConfigMap,
  145. GraphQLField,
  146. GraphQLFieldConfig,
  147. GraphQLFieldConfigArgumentMap,
  148. GraphQLFieldConfigMap,
  149. GraphQLFieldMap,
  150. GraphQLFieldResolver,
  151. GraphQLInputField,
  152. GraphQLInputFieldConfig,
  153. GraphQLInputFieldConfigMap,
  154. GraphQLInputFieldMap,
  155. GraphQLInputObjectTypeConfig,
  156. GraphQLInterfaceTypeConfig,
  157. GraphQLIsTypeOfFn,
  158. GraphQLObjectTypeConfig,
  159. GraphQLResolveInfo,
  160. ResponsePath,
  161. GraphQLScalarTypeConfig,
  162. GraphQLTypeResolver,
  163. GraphQLUnionTypeConfig,
  164. GraphQLScalarSerializer,
  165. GraphQLScalarValueParser,
  166. GraphQLScalarLiteralParser,
  167. } from './type/index';
  168. // Parse and operate on GraphQL language source files.
  169. export {
  170. Token,
  171. Source,
  172. Location,
  173. getLocation,
  174. // Print source location
  175. printLocation,
  176. printSourceLocation,
  177. // Lex
  178. Lexer,
  179. TokenKind,
  180. // Parse
  181. parse,
  182. parseValue,
  183. parseType,
  184. // Print
  185. print,
  186. // Visit
  187. visit,
  188. visitInParallel,
  189. getVisitFn,
  190. BREAK,
  191. Kind,
  192. DirectiveLocation,
  193. // Predicates
  194. isDefinitionNode,
  195. isExecutableDefinitionNode,
  196. isSelectionNode,
  197. isValueNode,
  198. isTypeNode,
  199. isTypeSystemDefinitionNode,
  200. isTypeDefinitionNode,
  201. isTypeSystemExtensionNode,
  202. isTypeExtensionNode,
  203. } from './language/index';
  204. export type {
  205. ParseOptions,
  206. SourceLocation,
  207. TokenKindEnum,
  208. KindEnum,
  209. DirectiveLocationEnum,
  210. // Visitor utilities
  211. ASTVisitor,
  212. Visitor,
  213. VisitFn,
  214. VisitorKeyMap,
  215. // AST nodes
  216. ASTNode,
  217. ASTKindToNode,
  218. // Each kind of AST node
  219. NameNode,
  220. DocumentNode,
  221. DefinitionNode,
  222. ExecutableDefinitionNode,
  223. OperationDefinitionNode,
  224. OperationTypeNode,
  225. VariableDefinitionNode,
  226. VariableNode,
  227. SelectionSetNode,
  228. SelectionNode,
  229. FieldNode,
  230. ArgumentNode,
  231. FragmentSpreadNode,
  232. InlineFragmentNode,
  233. FragmentDefinitionNode,
  234. ValueNode,
  235. IntValueNode,
  236. FloatValueNode,
  237. StringValueNode,
  238. BooleanValueNode,
  239. NullValueNode,
  240. EnumValueNode,
  241. ListValueNode,
  242. ObjectValueNode,
  243. ObjectFieldNode,
  244. DirectiveNode,
  245. TypeNode,
  246. NamedTypeNode,
  247. ListTypeNode,
  248. NonNullTypeNode,
  249. TypeSystemDefinitionNode,
  250. SchemaDefinitionNode,
  251. OperationTypeDefinitionNode,
  252. TypeDefinitionNode,
  253. ScalarTypeDefinitionNode,
  254. ObjectTypeDefinitionNode,
  255. FieldDefinitionNode,
  256. InputValueDefinitionNode,
  257. InterfaceTypeDefinitionNode,
  258. UnionTypeDefinitionNode,
  259. EnumTypeDefinitionNode,
  260. EnumValueDefinitionNode,
  261. InputObjectTypeDefinitionNode,
  262. DirectiveDefinitionNode,
  263. TypeSystemExtensionNode,
  264. SchemaExtensionNode,
  265. TypeExtensionNode,
  266. ScalarTypeExtensionNode,
  267. ObjectTypeExtensionNode,
  268. InterfaceTypeExtensionNode,
  269. UnionTypeExtensionNode,
  270. EnumTypeExtensionNode,
  271. InputObjectTypeExtensionNode,
  272. } from './language/index';
  273. // Execute GraphQL queries.
  274. export {
  275. execute,
  276. executeSync,
  277. defaultFieldResolver,
  278. defaultTypeResolver,
  279. responsePathAsArray,
  280. getDirectiveValues,
  281. } from './execution/index';
  282. export type {
  283. ExecutionArgs,
  284. ExecutionResult,
  285. FormattedExecutionResult,
  286. } from './execution/index';
  287. export { subscribe, createSourceEventStream } from './subscription/index';
  288. export type { SubscriptionArgs } from './subscription/index';
  289. // Validate GraphQL documents.
  290. export {
  291. validate,
  292. ValidationContext,
  293. // All validation rules in the GraphQL Specification.
  294. specifiedRules,
  295. // Individual validation rules.
  296. ExecutableDefinitionsRule,
  297. FieldsOnCorrectTypeRule,
  298. FragmentsOnCompositeTypesRule,
  299. KnownArgumentNamesRule,
  300. KnownDirectivesRule,
  301. KnownFragmentNamesRule,
  302. KnownTypeNamesRule,
  303. LoneAnonymousOperationRule,
  304. NoFragmentCyclesRule,
  305. NoUndefinedVariablesRule,
  306. NoUnusedFragmentsRule,
  307. NoUnusedVariablesRule,
  308. OverlappingFieldsCanBeMergedRule,
  309. PossibleFragmentSpreadsRule,
  310. ProvidedRequiredArgumentsRule,
  311. ScalarLeafsRule,
  312. SingleFieldSubscriptionsRule,
  313. UniqueArgumentNamesRule,
  314. UniqueDirectivesPerLocationRule,
  315. UniqueFragmentNamesRule,
  316. UniqueInputFieldNamesRule,
  317. UniqueOperationNamesRule,
  318. UniqueVariableNamesRule,
  319. ValuesOfCorrectTypeRule,
  320. VariablesAreInputTypesRule,
  321. VariablesInAllowedPositionRule,
  322. // SDL-specific validation rules
  323. LoneSchemaDefinitionRule,
  324. UniqueOperationTypesRule,
  325. UniqueTypeNamesRule,
  326. UniqueEnumValueNamesRule,
  327. UniqueFieldDefinitionNamesRule,
  328. UniqueDirectiveNamesRule,
  329. PossibleTypeExtensionsRule,
  330. // Custom validation rules
  331. NoDeprecatedCustomRule,
  332. NoSchemaIntrospectionCustomRule,
  333. } from './validation/index';
  334. export type { ValidationRule } from './validation/index';
  335. // Create, format, and print GraphQL errors.
  336. export {
  337. GraphQLError,
  338. syntaxError,
  339. locatedError,
  340. printError,
  341. formatError,
  342. } from './error/index';
  343. export type { GraphQLFormattedError } from './error/index';
  344. // Utilities for operating on GraphQL type schema and parsed sources.
  345. export {
  346. // Produce the GraphQL query recommended for a full schema introspection.
  347. // Accepts optional IntrospectionOptions.
  348. getIntrospectionQuery,
  349. // Gets the target Operation from a Document.
  350. getOperationAST,
  351. // Gets the Type for the target Operation AST.
  352. getOperationRootType,
  353. // Convert a GraphQLSchema to an IntrospectionQuery.
  354. introspectionFromSchema,
  355. // Build a GraphQLSchema from an introspection result.
  356. buildClientSchema,
  357. // Build a GraphQLSchema from a parsed GraphQL Schema language AST.
  358. buildASTSchema,
  359. // Build a GraphQLSchema from a GraphQL schema language document.
  360. buildSchema,
  361. // @deprecated: Get the description from a schema AST node and supports legacy
  362. // syntax for specifying descriptions - will be removed in v16.
  363. getDescription,
  364. // Extends an existing GraphQLSchema from a parsed GraphQL Schema
  365. // language AST.
  366. extendSchema,
  367. // Sort a GraphQLSchema.
  368. lexicographicSortSchema,
  369. // Print a GraphQLSchema to GraphQL Schema language.
  370. printSchema,
  371. // Print a GraphQLType to GraphQL Schema language.
  372. printType,
  373. // Prints the built-in introspection schema in the Schema Language
  374. // format.
  375. printIntrospectionSchema,
  376. // Create a GraphQLType from a GraphQL language AST.
  377. typeFromAST,
  378. // Create a JavaScript value from a GraphQL language AST with a Type.
  379. valueFromAST,
  380. // Create a JavaScript value from a GraphQL language AST without a Type.
  381. valueFromASTUntyped,
  382. // Create a GraphQL language AST from a JavaScript value.
  383. astFromValue,
  384. // A helper to use within recursive-descent visitors which need to be aware of
  385. // the GraphQL type system.
  386. TypeInfo,
  387. visitWithTypeInfo,
  388. // Coerces a JavaScript value to a GraphQL type, or produces errors.
  389. coerceInputValue,
  390. // Concatenates multiple AST together.
  391. concatAST,
  392. // Separates an AST into an AST per Operation.
  393. separateOperations,
  394. // Strips characters that are not significant to the validity or execution
  395. // of a GraphQL document.
  396. stripIgnoredCharacters,
  397. // Comparators for types
  398. isEqualType,
  399. isTypeSubTypeOf,
  400. doTypesOverlap,
  401. // Asserts a string is a valid GraphQL name.
  402. assertValidName,
  403. // Determine if a string is a valid GraphQL name.
  404. isValidNameError,
  405. // Compares two GraphQLSchemas and detects breaking changes.
  406. BreakingChangeType,
  407. DangerousChangeType,
  408. findBreakingChanges,
  409. findDangerousChanges,
  410. // @deprecated: Report all deprecated usage within a GraphQL document.
  411. findDeprecatedUsages,
  412. } from './utilities/index';
  413. export type {
  414. IntrospectionOptions,
  415. IntrospectionQuery,
  416. IntrospectionSchema,
  417. IntrospectionType,
  418. IntrospectionInputType,
  419. IntrospectionOutputType,
  420. IntrospectionScalarType,
  421. IntrospectionObjectType,
  422. IntrospectionInterfaceType,
  423. IntrospectionUnionType,
  424. IntrospectionEnumType,
  425. IntrospectionInputObjectType,
  426. IntrospectionTypeRef,
  427. IntrospectionInputTypeRef,
  428. IntrospectionOutputTypeRef,
  429. IntrospectionNamedTypeRef,
  430. IntrospectionListTypeRef,
  431. IntrospectionNonNullTypeRef,
  432. IntrospectionField,
  433. IntrospectionInputValue,
  434. IntrospectionEnumValue,
  435. IntrospectionDirective,
  436. BuildSchemaOptions,
  437. BreakingChange,
  438. DangerousChange,
  439. } from './utilities/index';