|
| 1 | +/* @flow */ |
1 | 2 | /**
|
2 | 3 | * Copyright (c) 2015, Facebook, Inc.
|
3 | 4 | * All rights reserved.
|
|
7 | 8 | * of patent rights can be found in the PATENTS file in the same directory.
|
8 | 9 | */
|
9 | 10 |
|
| 11 | +/** |
| 12 | + * GraphQL.js provides a reference implementation for the GraphQL specification |
| 13 | + * but is also a useful utility for operating on GraphQL files and building |
| 14 | + * sophisticated tools. |
| 15 | + * |
| 16 | + * This primary module exports a general purpose function for fulfilling all |
| 17 | + * steps of the GraphQL specification in a single operation, but also includes |
| 18 | + * utilities for every part of the GraphQL specification: |
| 19 | + * |
| 20 | + * - Parsing the GraphQL language. |
| 21 | + * - Building a GraphQL type schema. |
| 22 | + * - Validating a GraphQL request against a type schema. |
| 23 | + * - Executing a GraphQL request against a type schema. |
| 24 | + * |
| 25 | + * This also includes utility functions for operating on GraphQL types and |
| 26 | + * GraphQL documents to facilitate building tools. |
| 27 | + * |
| 28 | + * You may also import from each sub-directory directly. For example, the |
| 29 | + * following two import statements are equivalent: |
| 30 | + * |
| 31 | + * import { parse } from 'graphql'; |
| 32 | + * import { parse } from 'graphql/language'; |
| 33 | + */ |
| 34 | + |
10 | 35 | // The primary entry point into fulfilling a GraphQL request.
|
11 |
| -export { graphql } from './graphql'; |
| 36 | +export { |
| 37 | + graphql |
| 38 | +} from './graphql'; |
12 | 39 |
|
13 |
| -// Produce a GraphQL type schema. |
14 |
| -export { GraphQLSchema } from './type/schema'; |
15 | 40 |
|
16 |
| -// Define GraphQL types. |
| 41 | +// Create and operate on GraphQL type definitions and schema. |
17 | 42 | export {
|
| 43 | + GraphQLSchema, |
| 44 | + |
| 45 | + // Definitions |
18 | 46 | GraphQLScalarType,
|
19 | 47 | GraphQLObjectType,
|
20 | 48 | GraphQLInterfaceType,
|
21 | 49 | GraphQLUnionType,
|
22 | 50 | GraphQLEnumType,
|
23 | 51 | GraphQLInputObjectType,
|
24 | 52 | GraphQLList,
|
25 |
| - GraphQLNonNull |
26 |
| -} from './type/definition'; |
| 53 | + GraphQLNonNull, |
27 | 54 |
|
28 |
| -// Use pre-defined GraphQL scalar types. |
29 |
| -export { |
| 55 | + // Scalars |
30 | 56 | GraphQLInt,
|
31 | 57 | GraphQLFloat,
|
32 | 58 | GraphQLString,
|
33 | 59 | GraphQLBoolean,
|
34 |
| - GraphQLID |
35 |
| -} from './type/scalars'; |
| 60 | + GraphQLID, |
| 61 | + |
| 62 | + // Predicates |
| 63 | + isType, |
| 64 | + isInputType, |
| 65 | + isOutputType, |
| 66 | + isLeafType, |
| 67 | + isCompositeType, |
| 68 | + isAbstractType, |
| 69 | + |
| 70 | + // Un-modifiers |
| 71 | + getNullableType, |
| 72 | + getNamedType, |
| 73 | +} from './type'; |
| 74 | + |
| 75 | + |
| 76 | +// Parse and operate on GraphQL language source files. |
| 77 | +export { |
| 78 | + Source, |
| 79 | + getLocation, |
| 80 | + |
| 81 | + // Parse |
| 82 | + parse, |
| 83 | + parseValue, |
| 84 | + |
| 85 | + // Print |
| 86 | + print, |
| 87 | + |
| 88 | + // Visit |
| 89 | + visit, |
| 90 | + Kind, |
| 91 | + BREAK, |
| 92 | +} from './language'; |
| 93 | + |
| 94 | + |
| 95 | +// Execute GraphQL queries. |
| 96 | +export { |
| 97 | + execute, |
| 98 | +} from './execution'; |
| 99 | + |
| 100 | + |
| 101 | +// Validate GraphQL queries. |
| 102 | +export { |
| 103 | + validate, |
| 104 | + specifiedRules, |
| 105 | +} from './validation'; |
| 106 | + |
| 107 | + |
| 108 | +// Create and format GraphQL errors. |
| 109 | +export { |
| 110 | + GraphQLError, |
| 111 | + formatError, |
| 112 | +} from './error'; |
| 113 | + |
| 114 | + |
| 115 | +// Utilities for operating on GraphQL type schema and parsed sources. |
| 116 | +export { |
| 117 | + // The GraphQL query recommended for a full schema introspection. |
| 118 | + introspectionQuery, |
| 119 | + |
| 120 | + // Gets the target Operation from a Document |
| 121 | + getOperationAST, |
| 122 | + |
| 123 | + // Build a GraphQLSchema from an introspection result. |
| 124 | + buildClientSchema, |
| 125 | + |
| 126 | + // Build a GraphQLSchema from a parsed GraphQL Schema language AST. |
| 127 | + buildASTSchema, |
| 128 | + |
| 129 | + // Extends an existing GraphQLSchema from a parsed GraphQL Schema |
| 130 | + // language AST. |
| 131 | + extendSchema, |
| 132 | + |
| 133 | + // Print a GraphQLSchema to GraphQL Schema language. |
| 134 | + printSchema, |
| 135 | + |
| 136 | + // Create a GraphQLType from a GraphQL language AST. |
| 137 | + typeFromAST, |
| 138 | + |
| 139 | + // Create a JavaScript value from a GraphQL language AST. |
| 140 | + valueFromAST, |
| 141 | + |
| 142 | + // Create a GraphQL language AST from a JavaScript value. |
| 143 | + astFromValue, |
| 144 | + |
| 145 | + // A helper to use within recursive-descent visitors which need to be aware of |
| 146 | + // the GraphQL type system. |
| 147 | + TypeInfo, |
| 148 | + |
| 149 | + // Determine if JavaScript values adhere to a GraphQL type. |
| 150 | + isValidJSValue, |
| 151 | + |
| 152 | + // Determine if AST values adhere to a GraphQL type. |
| 153 | + isValidLiteralValue, |
36 | 154 |
|
37 |
| -// Format GraphQL errors. |
38 |
| -export { formatError } from './error/formatError'; |
| 155 | + // Concatenates multiple AST together. |
| 156 | + concatAST, |
| 157 | +} from './utilities'; |
0 commit comments