UNPKG

12.1 kBTypeScriptView 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/** The GraphQL.js version info. */
27export { version, versionInfo } from './version';
28/** The primary entry point into fulfilling a GraphQL request. */
29export type { GraphQLArgs } from './graphql';
30export { graphql, graphqlSync } from './graphql';
31/** Create and operate on GraphQL type definitions and schema. */
32export {
33 /** Definitions */
34 GraphQLSchema,
35 GraphQLDirective,
36 GraphQLScalarType,
37 GraphQLObjectType,
38 GraphQLInterfaceType,
39 GraphQLUnionType,
40 GraphQLEnumType,
41 GraphQLInputObjectType,
42 GraphQLList,
43 GraphQLNonNull,
44 /** Standard GraphQL Scalars */
45 specifiedScalarTypes,
46 GraphQLInt,
47 GraphQLFloat,
48 GraphQLString,
49 GraphQLBoolean,
50 GraphQLID,
51 /** Built-in Directives defined by the Spec */
52 specifiedDirectives,
53 GraphQLIncludeDirective,
54 GraphQLSkipDirective,
55 GraphQLDeprecatedDirective,
56 GraphQLSpecifiedByDirective,
57 /** "Enum" of Type Kinds */
58 TypeKind,
59 /** Constant Deprecation Reason */
60 DEFAULT_DEPRECATION_REASON,
61 /** GraphQL Types for introspection. */
62 introspectionTypes,
63 __Schema,
64 __Directive,
65 __DirectiveLocation,
66 __Type,
67 __Field,
68 __InputValue,
69 __EnumValue,
70 __TypeKind,
71 /** Meta-field definitions. */
72 SchemaMetaFieldDef,
73 TypeMetaFieldDef,
74 TypeNameMetaFieldDef,
75 /** Predicates */
76 isSchema,
77 isDirective,
78 isType,
79 isScalarType,
80 isObjectType,
81 isInterfaceType,
82 isUnionType,
83 isEnumType,
84 isInputObjectType,
85 isListType,
86 isNonNullType,
87 isInputType,
88 isOutputType,
89 isLeafType,
90 isCompositeType,
91 isAbstractType,
92 isWrappingType,
93 isNullableType,
94 isNamedType,
95 isRequiredArgument,
96 isRequiredInputField,
97 isSpecifiedScalarType,
98 isIntrospectionType,
99 isSpecifiedDirective,
100 /** Assertions */
101 assertSchema,
102 assertDirective,
103 assertType,
104 assertScalarType,
105 assertObjectType,
106 assertInterfaceType,
107 assertUnionType,
108 assertEnumType,
109 assertInputObjectType,
110 assertListType,
111 assertNonNullType,
112 assertInputType,
113 assertOutputType,
114 assertLeafType,
115 assertCompositeType,
116 assertAbstractType,
117 assertWrappingType,
118 assertNullableType,
119 assertNamedType,
120 /** Un-modifiers */
121 getNullableType,
122 getNamedType,
123 /** Validate GraphQL schema. */
124 validateSchema,
125 assertValidSchema,
126 /** Upholds the spec rules about naming. */
127 assertName,
128 assertEnumValueName,
129} from './type/index';
130export type {
131 GraphQLType,
132 GraphQLInputType,
133 GraphQLOutputType,
134 GraphQLLeafType,
135 GraphQLCompositeType,
136 GraphQLAbstractType,
137 GraphQLWrappingType,
138 GraphQLNullableType,
139 GraphQLNamedType,
140 GraphQLNamedInputType,
141 GraphQLNamedOutputType,
142 ThunkReadonlyArray,
143 ThunkObjMap,
144 GraphQLSchemaConfig,
145 GraphQLSchemaExtensions,
146 GraphQLDirectiveConfig,
147 GraphQLDirectiveExtensions,
148 GraphQLArgument,
149 GraphQLArgumentConfig,
150 GraphQLArgumentExtensions,
151 GraphQLEnumTypeConfig,
152 GraphQLEnumTypeExtensions,
153 GraphQLEnumValue,
154 GraphQLEnumValueConfig,
155 GraphQLEnumValueConfigMap,
156 GraphQLEnumValueExtensions,
157 GraphQLField,
158 GraphQLFieldConfig,
159 GraphQLFieldConfigArgumentMap,
160 GraphQLFieldConfigMap,
161 GraphQLFieldExtensions,
162 GraphQLFieldMap,
163 GraphQLFieldResolver,
164 GraphQLInputField,
165 GraphQLInputFieldConfig,
166 GraphQLInputFieldConfigMap,
167 GraphQLInputFieldExtensions,
168 GraphQLInputFieldMap,
169 GraphQLInputObjectTypeConfig,
170 GraphQLInputObjectTypeExtensions,
171 GraphQLInterfaceTypeConfig,
172 GraphQLInterfaceTypeExtensions,
173 GraphQLIsTypeOfFn,
174 GraphQLObjectTypeConfig,
175 GraphQLObjectTypeExtensions,
176 GraphQLResolveInfo,
177 ResponsePath,
178 GraphQLScalarTypeConfig,
179 GraphQLScalarTypeExtensions,
180 GraphQLTypeResolver,
181 GraphQLUnionTypeConfig,
182 GraphQLUnionTypeExtensions,
183 GraphQLScalarSerializer,
184 GraphQLScalarValueParser,
185 GraphQLScalarLiteralParser,
186} from './type/index';
187/** Parse and operate on GraphQL language source files. */
188export {
189 Token,
190 Source,
191 Location,
192 OperationTypeNode,
193 getLocation,
194 /** Print source location */
195 printLocation,
196 printSourceLocation,
197 /** Lex */
198 Lexer,
199 TokenKind,
200 /** Parse */
201 parse,
202 parseValue,
203 parseConstValue,
204 parseType,
205 /** Print */
206 print,
207 /** Visit */
208 visit,
209 visitInParallel,
210 getVisitFn,
211 getEnterLeaveForKind,
212 BREAK,
213 Kind,
214 DirectiveLocation,
215 /** Predicates */
216 isDefinitionNode,
217 isExecutableDefinitionNode,
218 isSelectionNode,
219 isValueNode,
220 isConstValueNode,
221 isTypeNode,
222 isTypeSystemDefinitionNode,
223 isTypeDefinitionNode,
224 isTypeSystemExtensionNode,
225 isTypeExtensionNode,
226} from './language/index';
227export type {
228 ParseOptions,
229 SourceLocation,
230 TokenKindEnum,
231 KindEnum,
232 DirectiveLocationEnum,
233 /** Visitor utilities */
234 ASTVisitor,
235 ASTVisitFn,
236 ASTVisitorKeyMap,
237 /** AST nodes */
238 ASTNode,
239 ASTKindToNode,
240 /** Each kind of AST node */
241 NameNode,
242 DocumentNode,
243 DefinitionNode,
244 ExecutableDefinitionNode,
245 OperationDefinitionNode,
246 VariableDefinitionNode,
247 VariableNode,
248 SelectionSetNode,
249 SelectionNode,
250 FieldNode,
251 ArgumentNode,
252 ConstArgumentNode,
253 FragmentSpreadNode,
254 InlineFragmentNode,
255 FragmentDefinitionNode,
256 ValueNode,
257 ConstValueNode,
258 IntValueNode,
259 FloatValueNode,
260 StringValueNode,
261 BooleanValueNode,
262 NullValueNode,
263 EnumValueNode,
264 ListValueNode,
265 ConstListValueNode,
266 ObjectValueNode,
267 ConstObjectValueNode,
268 ObjectFieldNode,
269 ConstObjectFieldNode,
270 DirectiveNode,
271 ConstDirectiveNode,
272 TypeNode,
273 NamedTypeNode,
274 ListTypeNode,
275 NonNullTypeNode,
276 TypeSystemDefinitionNode,
277 SchemaDefinitionNode,
278 OperationTypeDefinitionNode,
279 TypeDefinitionNode,
280 ScalarTypeDefinitionNode,
281 ObjectTypeDefinitionNode,
282 FieldDefinitionNode,
283 InputValueDefinitionNode,
284 InterfaceTypeDefinitionNode,
285 UnionTypeDefinitionNode,
286 EnumTypeDefinitionNode,
287 EnumValueDefinitionNode,
288 InputObjectTypeDefinitionNode,
289 DirectiveDefinitionNode,
290 TypeSystemExtensionNode,
291 SchemaExtensionNode,
292 TypeExtensionNode,
293 ScalarTypeExtensionNode,
294 ObjectTypeExtensionNode,
295 InterfaceTypeExtensionNode,
296 UnionTypeExtensionNode,
297 EnumTypeExtensionNode,
298 InputObjectTypeExtensionNode,
299} from './language/index';
300/** Execute GraphQL queries. */
301export {
302 execute,
303 executeSync,
304 defaultFieldResolver,
305 defaultTypeResolver,
306 responsePathAsArray,
307 getDirectiveValues,
308 subscribe,
309 createSourceEventStream,
310} from './execution/index';
311export type {
312 ExecutionArgs,
313 ExecutionResult,
314 FormattedExecutionResult,
315} from './execution/index';
316export type { SubscriptionArgs } from './subscription/index';
317/** Validate GraphQL documents. */
318export {
319 validate,
320 ValidationContext,
321 /** All validation rules in the GraphQL Specification. */
322 specifiedRules,
323 /** Individual validation rules. */
324 ExecutableDefinitionsRule,
325 FieldsOnCorrectTypeRule,
326 FragmentsOnCompositeTypesRule,
327 KnownArgumentNamesRule,
328 KnownDirectivesRule,
329 KnownFragmentNamesRule,
330 KnownTypeNamesRule,
331 LoneAnonymousOperationRule,
332 NoFragmentCyclesRule,
333 NoUndefinedVariablesRule,
334 NoUnusedFragmentsRule,
335 NoUnusedVariablesRule,
336 OverlappingFieldsCanBeMergedRule,
337 PossibleFragmentSpreadsRule,
338 ProvidedRequiredArgumentsRule,
339 ScalarLeafsRule,
340 SingleFieldSubscriptionsRule,
341 UniqueArgumentNamesRule,
342 UniqueDirectivesPerLocationRule,
343 UniqueFragmentNamesRule,
344 UniqueInputFieldNamesRule,
345 UniqueOperationNamesRule,
346 UniqueVariableNamesRule,
347 ValuesOfCorrectTypeRule,
348 VariablesAreInputTypesRule,
349 VariablesInAllowedPositionRule,
350 /** SDL-specific validation rules */
351 LoneSchemaDefinitionRule,
352 UniqueOperationTypesRule,
353 UniqueTypeNamesRule,
354 UniqueEnumValueNamesRule,
355 UniqueFieldDefinitionNamesRule,
356 UniqueArgumentDefinitionNamesRule,
357 UniqueDirectiveNamesRule,
358 PossibleTypeExtensionsRule,
359 /** Custom validation rules */
360 NoDeprecatedCustomRule,
361 NoSchemaIntrospectionCustomRule,
362} from './validation/index';
363export type { ValidationRule } from './validation/index';
364/** Create, format, and print GraphQL errors. */
365export {
366 GraphQLError,
367 syntaxError,
368 locatedError,
369 printError,
370 formatError,
371} from './error/index';
372export type {
373 GraphQLFormattedError,
374 GraphQLErrorExtensions,
375} from './error/index';
376/** Utilities for operating on GraphQL type schema and parsed sources. */
377export {
378 /**
379 * Produce the GraphQL query recommended for a full schema introspection.
380 * Accepts optional IntrospectionOptions.
381 */
382 getIntrospectionQuery,
383 /** Gets the target Operation from a Document. */
384 getOperationAST,
385 /** Gets the Type for the target Operation AST. */
386 getOperationRootType,
387 /** Convert a GraphQLSchema to an IntrospectionQuery. */
388 introspectionFromSchema,
389 /** Build a GraphQLSchema from an introspection result. */
390 buildClientSchema,
391 /** Build a GraphQLSchema from a parsed GraphQL Schema language AST. */
392 buildASTSchema,
393 /** Build a GraphQLSchema from a GraphQL schema language document. */
394 buildSchema,
395 /** Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST. */
396 extendSchema,
397 /** Sort a GraphQLSchema. */
398 lexicographicSortSchema,
399 /** Print a GraphQLSchema to GraphQL Schema language. */
400 printSchema,
401 /** Print a GraphQLType to GraphQL Schema language. */
402 printType,
403 /** Prints the built-in introspection schema in the Schema Language format. */
404 printIntrospectionSchema,
405 /** Create a GraphQLType from a GraphQL language AST. */
406 typeFromAST,
407 /** Create a JavaScript value from a GraphQL language AST with a Type. */
408 valueFromAST,
409 /** Create a JavaScript value from a GraphQL language AST without a Type. */
410 valueFromASTUntyped,
411 /** Create a GraphQL language AST from a JavaScript value. */
412 astFromValue,
413 /** A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system. */
414 TypeInfo,
415 visitWithTypeInfo,
416 /** Coerces a JavaScript value to a GraphQL type, or produces errors. */
417 coerceInputValue,
418 /** Concatenates multiple AST together. */
419 concatAST,
420 /** Separates an AST into an AST per Operation. */
421 separateOperations,
422 /** Strips characters that are not significant to the validity or execution of a GraphQL document. */
423 stripIgnoredCharacters,
424 /** Comparators for types */
425 isEqualType,
426 isTypeSubTypeOf,
427 doTypesOverlap,
428 /** Asserts a string is a valid GraphQL name. */
429 assertValidName,
430 /** Determine if a string is a valid GraphQL name. */
431 isValidNameError,
432 /** Compares two GraphQLSchemas and detects breaking changes. */
433 BreakingChangeType,
434 DangerousChangeType,
435 findBreakingChanges,
436 findDangerousChanges,
437} from './utilities/index';
438export type {
439 IntrospectionOptions,
440 IntrospectionQuery,
441 IntrospectionSchema,
442 IntrospectionType,
443 IntrospectionInputType,
444 IntrospectionOutputType,
445 IntrospectionScalarType,
446 IntrospectionObjectType,
447 IntrospectionInterfaceType,
448 IntrospectionUnionType,
449 IntrospectionEnumType,
450 IntrospectionInputObjectType,
451 IntrospectionTypeRef,
452 IntrospectionInputTypeRef,
453 IntrospectionOutputTypeRef,
454 IntrospectionNamedTypeRef,
455 IntrospectionListTypeRef,
456 IntrospectionNonNullTypeRef,
457 IntrospectionField,
458 IntrospectionInputValue,
459 IntrospectionEnumValue,
460 IntrospectionDirective,
461 BuildSchemaOptions,
462 BreakingChange,
463 DangerousChange,
464 TypedQueryDocumentNode,
465} from './utilities/index';