index.js.flow 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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. // "Enum" of Type Kinds
  56. TypeKind,
  57. // Constant Deprecation Reason
  58. DEFAULT_DEPRECATION_REASON,
  59. // GraphQL Types for introspection.
  60. introspectionTypes,
  61. __Schema,
  62. __Directive,
  63. __DirectiveLocation,
  64. __Type,
  65. __Field,
  66. __InputValue,
  67. __EnumValue,
  68. __TypeKind,
  69. // Meta-field definitions.
  70. SchemaMetaFieldDef,
  71. TypeMetaFieldDef,
  72. TypeNameMetaFieldDef,
  73. // Predicates
  74. isSchema,
  75. isDirective,
  76. isType,
  77. isScalarType,
  78. isObjectType,
  79. isInterfaceType,
  80. isUnionType,
  81. isEnumType,
  82. isInputObjectType,
  83. isListType,
  84. isNonNullType,
  85. isInputType,
  86. isOutputType,
  87. isLeafType,
  88. isCompositeType,
  89. isAbstractType,
  90. isWrappingType,
  91. isNullableType,
  92. isNamedType,
  93. isRequiredArgument,
  94. isRequiredInputField,
  95. isSpecifiedScalarType,
  96. isIntrospectionType,
  97. isSpecifiedDirective,
  98. // Assertions
  99. assertSchema,
  100. assertDirective,
  101. assertType,
  102. assertScalarType,
  103. assertObjectType,
  104. assertInterfaceType,
  105. assertUnionType,
  106. assertEnumType,
  107. assertInputObjectType,
  108. assertListType,
  109. assertNonNullType,
  110. assertInputType,
  111. assertOutputType,
  112. assertLeafType,
  113. assertCompositeType,
  114. assertAbstractType,
  115. assertWrappingType,
  116. assertNullableType,
  117. assertNamedType,
  118. // Un-modifiers
  119. getNullableType,
  120. getNamedType,
  121. // Validate GraphQL schema.
  122. validateSchema,
  123. assertValidSchema,
  124. } from './type';
  125. export type {
  126. GraphQLType,
  127. GraphQLInputType,
  128. GraphQLOutputType,
  129. GraphQLLeafType,
  130. GraphQLCompositeType,
  131. GraphQLAbstractType,
  132. GraphQLWrappingType,
  133. GraphQLNullableType,
  134. GraphQLNamedType,
  135. Thunk,
  136. GraphQLSchemaConfig,
  137. GraphQLDirectiveConfig,
  138. GraphQLArgument,
  139. GraphQLArgumentConfig,
  140. GraphQLEnumTypeConfig,
  141. GraphQLEnumValue,
  142. GraphQLEnumValueConfig,
  143. GraphQLEnumValueConfigMap,
  144. GraphQLField,
  145. GraphQLFieldConfig,
  146. GraphQLFieldConfigArgumentMap,
  147. GraphQLFieldConfigMap,
  148. GraphQLFieldMap,
  149. GraphQLFieldResolver,
  150. GraphQLInputField,
  151. GraphQLInputFieldConfig,
  152. GraphQLInputFieldConfigMap,
  153. GraphQLInputFieldMap,
  154. GraphQLInputObjectTypeConfig,
  155. GraphQLInterfaceTypeConfig,
  156. GraphQLIsTypeOfFn,
  157. GraphQLObjectTypeConfig,
  158. GraphQLResolveInfo,
  159. ResponsePath,
  160. GraphQLScalarTypeConfig,
  161. GraphQLTypeResolver,
  162. GraphQLUnionTypeConfig,
  163. GraphQLScalarSerializer,
  164. GraphQLScalarValueParser,
  165. GraphQLScalarLiteralParser,
  166. } from './type';
  167. // Parse and operate on GraphQL language source files.
  168. export {
  169. Source,
  170. getLocation,
  171. // Print source location
  172. printLocation,
  173. printSourceLocation,
  174. // Lex
  175. createLexer,
  176. TokenKind,
  177. // Parse
  178. parse,
  179. parseValue,
  180. parseType,
  181. // Print
  182. print,
  183. // Visit
  184. visit,
  185. visitInParallel,
  186. visitWithTypeInfo,
  187. getVisitFn,
  188. BREAK,
  189. Kind,
  190. DirectiveLocation,
  191. // Predicates
  192. isDefinitionNode,
  193. isExecutableDefinitionNode,
  194. isSelectionNode,
  195. isValueNode,
  196. isTypeNode,
  197. isTypeSystemDefinitionNode,
  198. isTypeDefinitionNode,
  199. isTypeSystemExtensionNode,
  200. isTypeExtensionNode,
  201. } from './language';
  202. export type {
  203. Lexer,
  204. ParseOptions,
  205. SourceLocation,
  206. Location,
  207. Token,
  208. TokenKindEnum,
  209. KindEnum,
  210. DirectiveLocationEnum,
  211. // Visitor utilities
  212. ASTVisitor,
  213. Visitor,
  214. VisitFn,
  215. VisitorKeyMap,
  216. // AST nodes
  217. ASTNode,
  218. ASTKindToNode,
  219. // Each kind of AST node
  220. NameNode,
  221. DocumentNode,
  222. DefinitionNode,
  223. ExecutableDefinitionNode,
  224. OperationDefinitionNode,
  225. OperationTypeNode,
  226. VariableDefinitionNode,
  227. VariableNode,
  228. SelectionSetNode,
  229. SelectionNode,
  230. FieldNode,
  231. ArgumentNode,
  232. FragmentSpreadNode,
  233. InlineFragmentNode,
  234. FragmentDefinitionNode,
  235. ValueNode,
  236. IntValueNode,
  237. FloatValueNode,
  238. StringValueNode,
  239. BooleanValueNode,
  240. NullValueNode,
  241. EnumValueNode,
  242. ListValueNode,
  243. ObjectValueNode,
  244. ObjectFieldNode,
  245. DirectiveNode,
  246. TypeNode,
  247. NamedTypeNode,
  248. ListTypeNode,
  249. NonNullTypeNode,
  250. TypeSystemDefinitionNode,
  251. SchemaDefinitionNode,
  252. OperationTypeDefinitionNode,
  253. TypeDefinitionNode,
  254. ScalarTypeDefinitionNode,
  255. ObjectTypeDefinitionNode,
  256. FieldDefinitionNode,
  257. InputValueDefinitionNode,
  258. InterfaceTypeDefinitionNode,
  259. UnionTypeDefinitionNode,
  260. EnumTypeDefinitionNode,
  261. EnumValueDefinitionNode,
  262. InputObjectTypeDefinitionNode,
  263. DirectiveDefinitionNode,
  264. TypeSystemExtensionNode,
  265. SchemaExtensionNode,
  266. TypeExtensionNode,
  267. ScalarTypeExtensionNode,
  268. ObjectTypeExtensionNode,
  269. InterfaceTypeExtensionNode,
  270. UnionTypeExtensionNode,
  271. EnumTypeExtensionNode,
  272. InputObjectTypeExtensionNode,
  273. } from './language';
  274. // Execute GraphQL queries.
  275. export {
  276. execute,
  277. defaultFieldResolver,
  278. defaultTypeResolver,
  279. responsePathAsArray,
  280. getDirectiveValues,
  281. } from './execution';
  282. export type {
  283. ExecutionArgs,
  284. ExecutionResult,
  285. FormattedExecutionResult,
  286. } from './execution';
  287. export { subscribe, createSourceEventStream } from './subscription';
  288. export type { SubscriptionArgs } from './subscription';
  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. } from './validation';
  331. export type { ValidationRule } from './validation';
  332. // Create, format, and print GraphQL errors.
  333. export {
  334. GraphQLError,
  335. syntaxError,
  336. locatedError,
  337. printError,
  338. formatError,
  339. } from './error';
  340. export type { GraphQLFormattedError } from './error';
  341. // Utilities for operating on GraphQL type schema and parsed sources.
  342. export {
  343. // Produce the GraphQL query recommended for a full schema introspection.
  344. // Accepts optional IntrospectionOptions.
  345. getIntrospectionQuery,
  346. // @deprecated: use getIntrospectionQuery - will be removed in v15.
  347. introspectionQuery,
  348. // Gets the target Operation from a Document.
  349. getOperationAST,
  350. // Gets the Type for the target Operation AST.
  351. getOperationRootType,
  352. // Convert a GraphQLSchema to an IntrospectionQuery.
  353. introspectionFromSchema,
  354. // Build a GraphQLSchema from an introspection result.
  355. buildClientSchema,
  356. // Build a GraphQLSchema from a parsed GraphQL Schema language AST.
  357. buildASTSchema,
  358. // Build a GraphQLSchema from a GraphQL schema language document.
  359. buildSchema,
  360. // @deprecated: Get the description from a schema AST node and supports legacy
  361. // syntax for specifying descriptions - will be removed in v16.
  362. getDescription,
  363. // Extends an existing GraphQLSchema from a parsed GraphQL Schema
  364. // language AST.
  365. extendSchema,
  366. // Sort a GraphQLSchema.
  367. lexicographicSortSchema,
  368. // Print a GraphQLSchema to GraphQL Schema language.
  369. printSchema,
  370. // Print a GraphQLType to GraphQL Schema language.
  371. printType,
  372. // Prints the built-in introspection schema in the Schema Language
  373. // format.
  374. printIntrospectionSchema,
  375. // Create a GraphQLType from a GraphQL language AST.
  376. typeFromAST,
  377. // Create a JavaScript value from a GraphQL language AST with a Type.
  378. valueFromAST,
  379. // Create a JavaScript value from a GraphQL language AST without a Type.
  380. valueFromASTUntyped,
  381. // Create a GraphQL language AST from a JavaScript value.
  382. astFromValue,
  383. // A helper to use within recursive-descent visitors which need to be aware of
  384. // the GraphQL type system.
  385. TypeInfo,
  386. // Coerces a JavaScript value to a GraphQL type, or produces errors.
  387. coerceInputValue,
  388. // @deprecated use coerceInputValue - will be removed in v15
  389. coerceValue,
  390. // @deprecated use coerceInputValue - will be removed in v15
  391. isValidJSValue,
  392. // @deprecated use validation - will be removed in v15
  393. isValidLiteralValue,
  394. // Concatenates multiple AST together.
  395. concatAST,
  396. // Separates an AST into an AST per Operation.
  397. separateOperations,
  398. // Strips characters that are not significant to the validity or execution
  399. // of a GraphQL document.
  400. stripIgnoredCharacters,
  401. // Comparators for types
  402. isEqualType,
  403. isTypeSubTypeOf,
  404. doTypesOverlap,
  405. // Asserts a string is a valid GraphQL name.
  406. assertValidName,
  407. // Determine if a string is a valid GraphQL name.
  408. isValidNameError,
  409. // Compares two GraphQLSchemas and detects breaking changes.
  410. BreakingChangeType,
  411. DangerousChangeType,
  412. findBreakingChanges,
  413. findDangerousChanges,
  414. // Report all deprecated usage within a GraphQL document.
  415. findDeprecatedUsages,
  416. } from './utilities';
  417. export type {
  418. IntrospectionOptions,
  419. IntrospectionQuery,
  420. IntrospectionSchema,
  421. IntrospectionType,
  422. IntrospectionInputType,
  423. IntrospectionOutputType,
  424. IntrospectionScalarType,
  425. IntrospectionObjectType,
  426. IntrospectionInterfaceType,
  427. IntrospectionUnionType,
  428. IntrospectionEnumType,
  429. IntrospectionInputObjectType,
  430. IntrospectionTypeRef,
  431. IntrospectionInputTypeRef,
  432. IntrospectionOutputTypeRef,
  433. IntrospectionNamedTypeRef,
  434. IntrospectionListTypeRef,
  435. IntrospectionNonNullTypeRef,
  436. IntrospectionField,
  437. IntrospectionInputValue,
  438. IntrospectionEnumValue,
  439. IntrospectionDirective,
  440. BuildSchemaOptions,
  441. BreakingChange,
  442. DangerousChange,
  443. } from './utilities';