UNPKG

7.35 kBJavaScriptView Raw
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 * import { parse } from 'graphql';
22 * import { parse } from 'graphql/language';
23 */
24// The GraphQL.js version info.
25export { version, versionInfo } from './version'; // The primary entry point into fulfilling a GraphQL request.
26
27export { graphql, graphqlSync } from './graphql'; // Create and operate on GraphQL type definitions and schema.
28
29export { // Definitions
30GraphQLSchema, GraphQLDirective, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType, GraphQLList, GraphQLNonNull, // Standard GraphQL Scalars
31specifiedScalarTypes, GraphQLInt, GraphQLFloat, GraphQLString, GraphQLBoolean, GraphQLID, // Built-in Directives defined by the Spec
32specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, // "Enum" of Type Kinds
33TypeKind, // Constant Deprecation Reason
34DEFAULT_DEPRECATION_REASON, // GraphQL Types for introspection.
35introspectionTypes, __Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind, // Meta-field definitions.
36SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, // Predicates
37isSchema, isDirective, isType, isScalarType, isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isListType, isNonNullType, isInputType, isOutputType, isLeafType, isCompositeType, isAbstractType, isWrappingType, isNullableType, isNamedType, isRequiredArgument, isRequiredInputField, isSpecifiedScalarType, isIntrospectionType, isSpecifiedDirective, // Assertions
38assertSchema, assertDirective, assertType, assertScalarType, assertObjectType, assertInterfaceType, assertUnionType, assertEnumType, assertInputObjectType, assertListType, assertNonNullType, assertInputType, assertOutputType, assertLeafType, assertCompositeType, assertAbstractType, assertWrappingType, assertNullableType, assertNamedType, // Un-modifiers
39getNullableType, getNamedType, // Validate GraphQL schema.
40validateSchema, assertValidSchema } from './type';
41// Parse and operate on GraphQL language source files.
42export { Source, getLocation, // Print source location
43printLocation, printSourceLocation, // Lex
44createLexer, TokenKind, // Parse
45parse, parseValue, parseType, // Print
46print, // Visit
47visit, visitInParallel, visitWithTypeInfo, getVisitFn, BREAK, Kind, DirectiveLocation, // Predicates
48isDefinitionNode, isExecutableDefinitionNode, isSelectionNode, isValueNode, isTypeNode, isTypeSystemDefinitionNode, isTypeDefinitionNode, isTypeSystemExtensionNode, isTypeExtensionNode } from './language';
49// Execute GraphQL queries.
50export { execute, defaultFieldResolver, defaultTypeResolver, responsePathAsArray, getDirectiveValues } from './execution';
51export { subscribe, createSourceEventStream } from './subscription';
52// Validate GraphQL documents.
53export { validate, ValidationContext, // All validation rules in the GraphQL Specification.
54specifiedRules, // Individual validation rules.
55FieldsOnCorrectTypeRule, FragmentsOnCompositeTypesRule, KnownArgumentNamesRule, KnownDirectivesRule, KnownFragmentNamesRule, KnownTypeNamesRule, LoneAnonymousOperationRule, NoFragmentCyclesRule, NoUndefinedVariablesRule, NoUnusedFragmentsRule, NoUnusedVariablesRule, OverlappingFieldsCanBeMergedRule, PossibleFragmentSpreadsRule, ProvidedRequiredArgumentsRule, ScalarLeafsRule, SingleFieldSubscriptionsRule, UniqueArgumentNamesRule, UniqueDirectivesPerLocationRule, UniqueFragmentNamesRule, UniqueInputFieldNamesRule, UniqueOperationNamesRule, UniqueVariableNamesRule, ValuesOfCorrectTypeRule, VariablesAreInputTypesRule, VariablesInAllowedPositionRule } from './validation';
56// Create, format, and print GraphQL errors.
57export { GraphQLError, syntaxError, locatedError, printError, formatError } from './error';
58// Utilities for operating on GraphQL type schema and parsed sources.
59export { // Produce the GraphQL query recommended for a full schema introspection.
60// Accepts optional IntrospectionOptions.
61getIntrospectionQuery, // @deprecated: use getIntrospectionQuery - will be removed in v15.
62introspectionQuery, // Gets the target Operation from a Document.
63getOperationAST, // Gets the Type for the target Operation AST.
64getOperationRootType, // Convert a GraphQLSchema to an IntrospectionQuery.
65introspectionFromSchema, // Build a GraphQLSchema from an introspection result.
66buildClientSchema, // Build a GraphQLSchema from a parsed GraphQL Schema language AST.
67buildASTSchema, // Build a GraphQLSchema from a GraphQL schema language document.
68buildSchema, // @deprecated: Get the description from a schema AST node and supports legacy
69// syntax for specifying descriptions - will be removed in v16.
70getDescription, // Extends an existing GraphQLSchema from a parsed GraphQL Schema
71// language AST.
72extendSchema, // Sort a GraphQLSchema.
73lexicographicSortSchema, // Print a GraphQLSchema to GraphQL Schema language.
74printSchema, // Print a GraphQLType to GraphQL Schema language.
75printType, // Prints the built-in introspection schema in the Schema Language
76// format.
77printIntrospectionSchema, // Create a GraphQLType from a GraphQL language AST.
78typeFromAST, // Create a JavaScript value from a GraphQL language AST with a Type.
79valueFromAST, // Create a JavaScript value from a GraphQL language AST without a Type.
80valueFromASTUntyped, // Create a GraphQL language AST from a JavaScript value.
81astFromValue, // A helper to use within recursive-descent visitors which need to be aware of
82// the GraphQL type system.
83TypeInfo, // Coerces a JavaScript value to a GraphQL type, or produces errors.
84coerceInputValue, // @deprecated use coerceInputValue - will be removed in v15
85coerceValue, // @deprecated use coerceInputValue - will be removed in v15
86isValidJSValue, // @deprecated use validation - will be removed in v15
87isValidLiteralValue, // Concatenates multiple AST together.
88concatAST, // Separates an AST into an AST per Operation.
89separateOperations, // Strips characters that are not significant to the validity or execution
90// of a GraphQL document.
91stripIgnoredCharacters, // Comparators for types
92isEqualType, isTypeSubTypeOf, doTypesOverlap, // Asserts a string is a valid GraphQL name.
93assertValidName, // Determine if a string is a valid GraphQL name.
94isValidNameError, // Compares two GraphQLSchemas and detects breaking changes.
95BreakingChangeType, DangerousChangeType, findBreakingChanges, findDangerousChanges, // Report all deprecated usage within a GraphQL document.
96findDeprecatedUsages } from './utilities';