Skip to content

Commit 4547904

Browse files
committed
Export all public API from top module
This exposes the full GraphQL.js API from the top level module, which hopefully will make it easier to find and use all of the utilities this library provides. This closes #143
1 parent 7011034 commit 4547904

File tree

1 file changed

+131
-12
lines changed

1 file changed

+131
-12
lines changed

src/index.js

Lines changed: 131 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* @flow */
12
/**
23
* Copyright (c) 2015, Facebook, Inc.
34
* All rights reserved.
@@ -7,32 +8,150 @@
78
* of patent rights can be found in the PATENTS file in the same directory.
89
*/
910

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+
1035
// The primary entry point into fulfilling a GraphQL request.
11-
export { graphql } from './graphql';
36+
export {
37+
graphql
38+
} from './graphql';
1239

13-
// Produce a GraphQL type schema.
14-
export { GraphQLSchema } from './type/schema';
1540

16-
// Define GraphQL types.
41+
// Create and operate on GraphQL type definitions and schema.
1742
export {
43+
GraphQLSchema,
44+
45+
// Definitions
1846
GraphQLScalarType,
1947
GraphQLObjectType,
2048
GraphQLInterfaceType,
2149
GraphQLUnionType,
2250
GraphQLEnumType,
2351
GraphQLInputObjectType,
2452
GraphQLList,
25-
GraphQLNonNull
26-
} from './type/definition';
53+
GraphQLNonNull,
2754

28-
// Use pre-defined GraphQL scalar types.
29-
export {
55+
// Scalars
3056
GraphQLInt,
3157
GraphQLFloat,
3258
GraphQLString,
3359
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,
36154

37-
// Format GraphQL errors.
38-
export { formatError } from './error/formatError';
155+
// Concatenates multiple AST together.
156+
concatAST,
157+
} from './utilities';

0 commit comments

Comments
 (0)