UNPKG

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