UNPKG

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