UNPKG

11.1 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 FieldsOnCorrectTypeRule,
306 FragmentsOnCompositeTypesRule,
307 KnownArgumentNamesRule,
308 KnownDirectivesRule,
309 KnownFragmentNamesRule,
310 KnownTypeNamesRule,
311 LoneAnonymousOperationRule,
312 NoFragmentCyclesRule,
313 NoUndefinedVariablesRule,
314 NoUnusedFragmentsRule,
315 NoUnusedVariablesRule,
316 OverlappingFieldsCanBeMergedRule,
317 PossibleFragmentSpreadsRule,
318 ProvidedRequiredArgumentsRule,
319 ScalarLeafsRule,
320 SingleFieldSubscriptionsRule,
321 UniqueArgumentNamesRule,
322 UniqueDirectivesPerLocationRule,
323 UniqueFragmentNamesRule,
324 UniqueInputFieldNamesRule,
325 UniqueOperationNamesRule,
326 UniqueVariableNamesRule,
327 ValuesOfCorrectTypeRule,
328 VariablesAreInputTypesRule,
329 VariablesInAllowedPositionRule,
330 ValidationRule,
331} from './validation';
332
333// Create, format, and print GraphQL errors.
334export {
335 GraphQLError,
336 syntaxError,
337 locatedError,
338 printError,
339 formatError,
340 GraphQLFormattedError,
341} from './error';
342
343// Utilities for operating on GraphQL type schema and parsed sources.
344export {
345 // Produce the GraphQL query recommended for a full schema introspection.
346 // Accepts optional IntrospectionOptions.
347 getIntrospectionQuery,
348 // @deprecated: use getIntrospectionQuery - will be removed in v15.
349 introspectionQuery,
350 // Gets the target Operation from a Document.
351 getOperationAST,
352 // Gets the Type for the target Operation AST.
353 getOperationRootType,
354 // Convert a GraphQLSchema to an IntrospectionQuery.
355 introspectionFromSchema,
356 // Build a GraphQLSchema from an introspection result.
357 buildClientSchema,
358 // Build a GraphQLSchema from a parsed GraphQL Schema language AST.
359 buildASTSchema,
360 // Build a GraphQLSchema from a GraphQL schema language document.
361 buildSchema,
362 // @deprecated: Get the description from a schema AST node and supports legacy
363 // syntax for specifying descriptions - will be removed in v16.
364 getDescription,
365 // Extends an existing GraphQLSchema from a parsed GraphQL Schema
366 // language AST.
367 extendSchema,
368 // Sort a GraphQLSchema.
369 lexicographicSortSchema,
370 // Print a GraphQLSchema to GraphQL Schema language.
371 printSchema,
372 // Print a GraphQLType to GraphQL Schema language.
373 printType,
374 // Prints the built-in introspection schema in the Schema Language
375 // format.
376 printIntrospectionSchema,
377 // Create a GraphQLType from a GraphQL language AST.
378 typeFromAST,
379 // Create a JavaScript value from a GraphQL language AST with a Type.
380 valueFromAST,
381 // Create a JavaScript value from a GraphQL language AST without a Type.
382 valueFromASTUntyped,
383 // Create a GraphQL language AST from a JavaScript value.
384 astFromValue,
385 // A helper to use within recursive-descent visitors which need to be aware of
386 // the GraphQL type system.
387 TypeInfo,
388 // Coerces a JavaScript value to a GraphQL type, or produces errors.
389 coerceInputValue,
390 // @deprecated use coerceInputValue - will be removed in v15
391 coerceValue,
392 // @deprecated use coerceInputValue - will be removed in v15
393 isValidJSValue,
394 // @deprecated use validation - will be removed in v15
395 isValidLiteralValue,
396 // Concatenates multiple AST together.
397 concatAST,
398 // Separates an AST into an AST per Operation.
399 separateOperations,
400 // Strips characters that are not significant to the validity or execution
401 // of a GraphQL document.
402 stripIgnoredCharacters,
403 // Comparators for types
404 isEqualType,
405 isTypeSubTypeOf,
406 doTypesOverlap,
407 // Asserts a string is a valid GraphQL name.
408 assertValidName,
409 // Determine if a string is a valid GraphQL name.
410 isValidNameError,
411 // Compares two GraphQLSchemas and detects breaking changes.
412 BreakingChangeType,
413 DangerousChangeType,
414 findBreakingChanges,
415 findDangerousChanges,
416 // Report all deprecated usage within a GraphQL document.
417 findDeprecatedUsages,
418} from './utilities';
419
420export {
421 IntrospectionOptions,
422 IntrospectionQuery,
423 IntrospectionSchema,
424 IntrospectionType,
425 IntrospectionInputType,
426 IntrospectionOutputType,
427 IntrospectionScalarType,
428 IntrospectionObjectType,
429 IntrospectionInterfaceType,
430 IntrospectionUnionType,
431 IntrospectionEnumType,
432 IntrospectionInputObjectType,
433 IntrospectionTypeRef,
434 IntrospectionInputTypeRef,
435 IntrospectionOutputTypeRef,
436 IntrospectionNamedTypeRef,
437 IntrospectionListTypeRef,
438 IntrospectionNonNullTypeRef,
439 IntrospectionField,
440 IntrospectionInputValue,
441 IntrospectionEnumValue,
442 IntrospectionDirective,
443 BuildSchemaOptions,
444 BreakingChange,
445 DangerousChange,
446} from './utilities';