UNPKG

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