UNPKG

7.6 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.
55ExecutableDefinitionsRule, FieldsOnCorrectTypeRule, FragmentsOnCompositeTypesRule, KnownArgumentNamesRule, KnownDirectivesRule, KnownFragmentNamesRule, KnownTypeNamesRule, LoneAnonymousOperationRule, NoFragmentCyclesRule, NoUndefinedVariablesRule, NoUnusedFragmentsRule, NoUnusedVariablesRule, OverlappingFieldsCanBeMergedRule, PossibleFragmentSpreadsRule, ProvidedRequiredArgumentsRule, ScalarLeafsRule, SingleFieldSubscriptionsRule, UniqueArgumentNamesRule, UniqueDirectivesPerLocationRule, UniqueFragmentNamesRule, UniqueInputFieldNamesRule, UniqueOperationNamesRule, UniqueVariableNamesRule, ValuesOfCorrectTypeRule, VariablesAreInputTypesRule, VariablesInAllowedPositionRule, // SDL-specific validation rules
56LoneSchemaDefinitionRule, UniqueOperationTypesRule, UniqueTypeNamesRule, UniqueEnumValueNamesRule, UniqueFieldDefinitionNamesRule, UniqueDirectiveNamesRule, PossibleTypeExtensionsRule } from './validation';
57// Create, format, and print GraphQL errors.
58export { GraphQLError, syntaxError, locatedError, printError, formatError } from './error';
59// Utilities for operating on GraphQL type schema and parsed sources.
60export { // Produce the GraphQL query recommended for a full schema introspection.
61// Accepts optional IntrospectionOptions.
62getIntrospectionQuery, // @deprecated: use getIntrospectionQuery - will be removed in v15.
63introspectionQuery, // Gets the target Operation from a Document.
64getOperationAST, // Gets the Type for the target Operation AST.
65getOperationRootType, // Convert a GraphQLSchema to an IntrospectionQuery.
66introspectionFromSchema, // Build a GraphQLSchema from an introspection result.
67buildClientSchema, // Build a GraphQLSchema from a parsed GraphQL Schema language AST.
68buildASTSchema, // Build a GraphQLSchema from a GraphQL schema language document.
69buildSchema, // @deprecated: Get the description from a schema AST node and supports legacy
70// syntax for specifying descriptions - will be removed in v16.
71getDescription, // Extends an existing GraphQLSchema from a parsed GraphQL Schema
72// language AST.
73extendSchema, // Sort a GraphQLSchema.
74lexicographicSortSchema, // Print a GraphQLSchema to GraphQL Schema language.
75printSchema, // Print a GraphQLType to GraphQL Schema language.
76printType, // Prints the built-in introspection schema in the Schema Language
77// format.
78printIntrospectionSchema, // Create a GraphQLType from a GraphQL language AST.
79typeFromAST, // Create a JavaScript value from a GraphQL language AST with a Type.
80valueFromAST, // Create a JavaScript value from a GraphQL language AST without a Type.
81valueFromASTUntyped, // Create a GraphQL language AST from a JavaScript value.
82astFromValue, // A helper to use within recursive-descent visitors which need to be aware of
83// the GraphQL type system.
84TypeInfo, // Coerces a JavaScript value to a GraphQL type, or produces errors.
85coerceInputValue, // @deprecated use coerceInputValue - will be removed in v15
86coerceValue, // @deprecated use coerceInputValue - will be removed in v15
87isValidJSValue, // @deprecated use validation - will be removed in v15
88isValidLiteralValue, // Concatenates multiple AST together.
89concatAST, // Separates an AST into an AST per Operation.
90separateOperations, // Strips characters that are not significant to the validity or execution
91// of a GraphQL document.
92stripIgnoredCharacters, // Comparators for types
93isEqualType, isTypeSubTypeOf, doTypesOverlap, // Asserts a string is a valid GraphQL name.
94assertValidName, // Determine if a string is a valid GraphQL name.
95isValidNameError, // Compares two GraphQLSchemas and detects breaking changes.
96BreakingChangeType, DangerousChangeType, findBreakingChanges, findDangerousChanges, // Report all deprecated usage within a GraphQL document.
97findDeprecatedUsages } from './utilities';