index.mjs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /**
  2. * GraphQL.js provides a reference implementation for the GraphQL specification
  3. * but is also a useful utility for operating on GraphQL files and building
  4. * sophisticated tools.
  5. *
  6. * This primary module exports a general purpose function for fulfilling all
  7. * steps of the GraphQL specification in a single operation, but also includes
  8. * utilities for every part of the GraphQL specification:
  9. *
  10. * - Parsing the GraphQL language.
  11. * - Building a GraphQL type schema.
  12. * - Validating a GraphQL request against a type schema.
  13. * - Executing a GraphQL request against a type schema.
  14. *
  15. * This also includes utility functions for operating on GraphQL types and
  16. * GraphQL documents to facilitate building tools.
  17. *
  18. * You may also import from each sub-directory directly. For example, the
  19. * following two import statements are equivalent:
  20. *
  21. * ```ts
  22. * import { parse } from 'graphql';
  23. * import { parse } from 'graphql/language';
  24. * ```
  25. *
  26. * @packageDocumentation
  27. */
  28. // The GraphQL.js version info.
  29. export { version, versionInfo } from './version.mjs'; // The primary entry point into fulfilling a GraphQL request.
  30. export { graphql, graphqlSync } from './graphql.mjs'; // Create and operate on GraphQL type definitions and schema.
  31. export {
  32. resolveObjMapThunk,
  33. resolveReadonlyArrayThunk, // Definitions
  34. GraphQLSchema,
  35. GraphQLDirective,
  36. GraphQLScalarType,
  37. GraphQLObjectType,
  38. GraphQLInterfaceType,
  39. GraphQLUnionType,
  40. GraphQLEnumType,
  41. GraphQLInputObjectType,
  42. GraphQLList,
  43. GraphQLNonNull, // Standard GraphQL Scalars
  44. specifiedScalarTypes,
  45. GraphQLInt,
  46. GraphQLFloat,
  47. GraphQLString,
  48. GraphQLBoolean,
  49. GraphQLID, // Int boundaries constants
  50. GRAPHQL_MAX_INT,
  51. GRAPHQL_MIN_INT, // Built-in Directives defined by the Spec
  52. specifiedDirectives,
  53. GraphQLIncludeDirective,
  54. GraphQLSkipDirective,
  55. GraphQLDeprecatedDirective,
  56. GraphQLSpecifiedByDirective, // "Enum" of Type Kinds
  57. TypeKind, // Constant Deprecation Reason
  58. DEFAULT_DEPRECATION_REASON, // GraphQL Types for introspection.
  59. introspectionTypes,
  60. __Schema,
  61. __Directive,
  62. __DirectiveLocation,
  63. __Type,
  64. __Field,
  65. __InputValue,
  66. __EnumValue,
  67. __TypeKind, // Meta-field definitions.
  68. SchemaMetaFieldDef,
  69. TypeMetaFieldDef,
  70. TypeNameMetaFieldDef, // Predicates
  71. isSchema,
  72. isDirective,
  73. isType,
  74. isScalarType,
  75. isObjectType,
  76. isInterfaceType,
  77. isUnionType,
  78. isEnumType,
  79. isInputObjectType,
  80. isListType,
  81. isNonNullType,
  82. isInputType,
  83. isOutputType,
  84. isLeafType,
  85. isCompositeType,
  86. isAbstractType,
  87. isWrappingType,
  88. isNullableType,
  89. isNamedType,
  90. isRequiredArgument,
  91. isRequiredInputField,
  92. isSpecifiedScalarType,
  93. isIntrospectionType,
  94. isSpecifiedDirective, // Assertions
  95. assertSchema,
  96. assertDirective,
  97. assertType,
  98. assertScalarType,
  99. assertObjectType,
  100. assertInterfaceType,
  101. assertUnionType,
  102. assertEnumType,
  103. assertInputObjectType,
  104. assertListType,
  105. assertNonNullType,
  106. assertInputType,
  107. assertOutputType,
  108. assertLeafType,
  109. assertCompositeType,
  110. assertAbstractType,
  111. assertWrappingType,
  112. assertNullableType,
  113. assertNamedType, // Un-modifiers
  114. getNullableType,
  115. getNamedType, // Validate GraphQL schema.
  116. validateSchema,
  117. assertValidSchema, // Upholds the spec rules about naming.
  118. assertName,
  119. assertEnumValueName,
  120. } from './type/index.mjs';
  121. // Parse and operate on GraphQL language source files.
  122. export {
  123. Token,
  124. Source,
  125. Location,
  126. OperationTypeNode,
  127. getLocation, // Print source location.
  128. printLocation,
  129. printSourceLocation, // Lex
  130. Lexer,
  131. TokenKind, // Parse
  132. parse,
  133. parseValue,
  134. parseConstValue,
  135. parseType, // Print
  136. print, // Visit
  137. visit,
  138. visitInParallel,
  139. getVisitFn,
  140. getEnterLeaveForKind,
  141. BREAK,
  142. Kind,
  143. DirectiveLocation, // Predicates
  144. isDefinitionNode,
  145. isExecutableDefinitionNode,
  146. isSelectionNode,
  147. isValueNode,
  148. isConstValueNode,
  149. isTypeNode,
  150. isTypeSystemDefinitionNode,
  151. isTypeDefinitionNode,
  152. isTypeSystemExtensionNode,
  153. isTypeExtensionNode,
  154. } from './language/index.mjs';
  155. // Execute GraphQL queries.
  156. export {
  157. execute,
  158. executeSync,
  159. defaultFieldResolver,
  160. defaultTypeResolver,
  161. responsePathAsArray,
  162. getArgumentValues,
  163. getVariableValues,
  164. getDirectiveValues,
  165. subscribe,
  166. createSourceEventStream,
  167. } from './execution/index.mjs';
  168. // Validate GraphQL documents.
  169. export {
  170. validate,
  171. ValidationContext, // All validation rules in the GraphQL Specification.
  172. specifiedRules, // Individual validation rules.
  173. ExecutableDefinitionsRule,
  174. FieldsOnCorrectTypeRule,
  175. FragmentsOnCompositeTypesRule,
  176. KnownArgumentNamesRule,
  177. KnownDirectivesRule,
  178. KnownFragmentNamesRule,
  179. KnownTypeNamesRule,
  180. LoneAnonymousOperationRule,
  181. NoFragmentCyclesRule,
  182. NoUndefinedVariablesRule,
  183. NoUnusedFragmentsRule,
  184. NoUnusedVariablesRule,
  185. OverlappingFieldsCanBeMergedRule,
  186. PossibleFragmentSpreadsRule,
  187. ProvidedRequiredArgumentsRule,
  188. ScalarLeafsRule,
  189. SingleFieldSubscriptionsRule,
  190. UniqueArgumentNamesRule,
  191. UniqueDirectivesPerLocationRule,
  192. UniqueFragmentNamesRule,
  193. UniqueInputFieldNamesRule,
  194. UniqueOperationNamesRule,
  195. UniqueVariableNamesRule,
  196. ValuesOfCorrectTypeRule,
  197. VariablesAreInputTypesRule,
  198. VariablesInAllowedPositionRule, // SDL-specific validation rules
  199. LoneSchemaDefinitionRule,
  200. UniqueOperationTypesRule,
  201. UniqueTypeNamesRule,
  202. UniqueEnumValueNamesRule,
  203. UniqueFieldDefinitionNamesRule,
  204. UniqueArgumentDefinitionNamesRule,
  205. UniqueDirectiveNamesRule,
  206. PossibleTypeExtensionsRule, // Custom validation rules
  207. NoDeprecatedCustomRule,
  208. NoSchemaIntrospectionCustomRule,
  209. } from './validation/index.mjs';
  210. // Create, format, and print GraphQL errors.
  211. export {
  212. GraphQLError,
  213. syntaxError,
  214. locatedError,
  215. printError,
  216. formatError,
  217. } from './error/index.mjs';
  218. // Utilities for operating on GraphQL type schema and parsed sources.
  219. export {
  220. // Produce the GraphQL query recommended for a full schema introspection.
  221. // Accepts optional IntrospectionOptions.
  222. getIntrospectionQuery, // Gets the target Operation from a Document.
  223. getOperationAST, // Gets the Type for the target Operation AST.
  224. getOperationRootType, // Convert a GraphQLSchema to an IntrospectionQuery.
  225. introspectionFromSchema, // Build a GraphQLSchema from an introspection result.
  226. buildClientSchema, // Build a GraphQLSchema from a parsed GraphQL Schema language AST.
  227. buildASTSchema, // Build a GraphQLSchema from a GraphQL schema language document.
  228. buildSchema, // Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST.
  229. extendSchema, // Sort a GraphQLSchema.
  230. lexicographicSortSchema, // Print a GraphQLSchema to GraphQL Schema language.
  231. printSchema, // Print a GraphQLType to GraphQL Schema language.
  232. printType, // Prints the built-in introspection schema in the Schema Language format.
  233. printIntrospectionSchema, // Create a GraphQLType from a GraphQL language AST.
  234. typeFromAST, // Create a JavaScript value from a GraphQL language AST with a Type.
  235. valueFromAST, // Create a JavaScript value from a GraphQL language AST without a Type.
  236. valueFromASTUntyped, // Create a GraphQL language AST from a JavaScript value.
  237. astFromValue, // A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system.
  238. TypeInfo,
  239. visitWithTypeInfo, // Coerces a JavaScript value to a GraphQL type, or produces errors.
  240. coerceInputValue, // Concatenates multiple AST together.
  241. concatAST, // Separates an AST into an AST per Operation.
  242. separateOperations, // Strips characters that are not significant to the validity or execution of a GraphQL document.
  243. stripIgnoredCharacters, // Comparators for types
  244. isEqualType,
  245. isTypeSubTypeOf,
  246. doTypesOverlap, // Asserts a string is a valid GraphQL name.
  247. assertValidName, // Determine if a string is a valid GraphQL name.
  248. isValidNameError, // Compares two GraphQLSchemas and detects breaking changes.
  249. BreakingChangeType,
  250. DangerousChangeType,
  251. findBreakingChanges,
  252. findDangerousChanges,
  253. } from './utilities/index.mjs';