Skip to content

Commit 55ad422

Browse files
committed
Export flow types from index.js
This adds all flow types exported from individual files to relevant index.js files as well. This enables those using graphql.js with flow to write something like: ```js import type { ... } from 'graphql' ```
1 parent b93f049 commit 55ad422

File tree

13 files changed

+283
-40
lines changed

13 files changed

+283
-40
lines changed

src/error/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ export { GraphQLError } from './GraphQLError';
1212
export { syntaxError } from './syntaxError';
1313
export { locatedError } from './locatedError';
1414
export { formatError } from './formatError';
15+
16+
export type {
17+
GraphQLFormattedError,
18+
GraphQLErrorLocation
19+
} from './formatError';

src/execution/execute.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import type {
3131
GraphQLType,
3232
GraphQLLeafType,
3333
GraphQLAbstractType,
34-
GraphQLFieldDefinition,
34+
GraphQLField,
3535
GraphQLFieldResolveFn,
3636
GraphQLResolveInfo,
3737
} from '../type/definition';
@@ -605,7 +605,7 @@ function resolveField(
605605
// function. Returns the result of resolveFn or the abrupt-return Error object.
606606
function resolveOrError(
607607
exeContext: ExecutionContext,
608-
fieldDef: GraphQLFieldDefinition,
608+
fieldDef: GraphQLField,
609609
fieldAST: Field,
610610
resolveFn: GraphQLFieldResolveFn<*>,
611611
source: mixed,
@@ -1051,7 +1051,7 @@ function getFieldDef(
10511051
schema: GraphQLSchema,
10521052
parentType: GraphQLObjectType,
10531053
fieldName: string
1054-
): ?GraphQLFieldDefinition {
1054+
): ?GraphQLField {
10551055
if (fieldName === SchemaMetaFieldDef.name &&
10561056
schema.getQueryType() === parentType) {
10571057
return SchemaMetaFieldDef;

src/execution/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
*/
99

1010
export { execute } from './execute';
11+
12+
export type { ExecutionResult } from './execute';

src/execution/values.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
} from '../type/definition';
3232
import type {
3333
GraphQLInputType,
34-
GraphQLFieldDefinition
34+
GraphQLField
3535
} from '../type/definition';
3636
import type { GraphQLDirective } from '../type/directives';
3737
import type { GraphQLSchema } from '../type/schema';
@@ -104,7 +104,7 @@ export function getVariableValues(
104104
* definitions and list of argument AST nodes.
105105
*/
106106
export function getArgumentValues(
107-
def: GraphQLFieldDefinition | GraphQLDirective,
107+
def: GraphQLField | GraphQLDirective,
108108
node: Field | Directive,
109109
variableValues?: ?{ [key: string]: mixed }
110110
): { [key: string]: mixed } {

src/index.js

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,45 @@ export {
103103
getNamedType,
104104
} from './type';
105105

106+
export type {
107+
DirectiveLocationEnum,
108+
109+
GraphQLType,
110+
GraphQLInputType,
111+
GraphQLOutputType,
112+
GraphQLLeafType,
113+
GraphQLCompositeType,
114+
GraphQLAbstractType,
115+
GraphQLNullableType,
116+
GraphQLNamedType,
117+
118+
Thunk,
119+
GraphQLArgument,
120+
GraphQLArgumentConfig,
121+
GraphQLEnumTypeConfig,
122+
GraphQLEnumValue,
123+
GraphQLEnumValueConfig,
124+
GraphQLEnumValueConfigMap,
125+
GraphQLField,
126+
GraphQLFieldConfig,
127+
GraphQLFieldConfigArgumentMap,
128+
GraphQLFieldConfigMap,
129+
GraphQLFieldMap,
130+
GraphQLFieldResolveFn,
131+
GraphQLInputField,
132+
GraphQLInputFieldConfig,
133+
GraphQLInputFieldConfigMap,
134+
GraphQLInputFieldMap,
135+
GraphQLInputObjectTypeConfig,
136+
GraphQLInterfaceTypeConfig,
137+
GraphQLIsTypeOfFn,
138+
GraphQLObjectTypeConfig,
139+
GraphQLResolveInfo,
140+
GraphQLScalarTypeConfig,
141+
GraphQLTypeResolveFn,
142+
GraphQLUnionTypeConfig,
143+
} from './type';
144+
106145

107146
// Parse and operate on GraphQL language source files.
108147
export {
@@ -126,12 +165,70 @@ export {
126165
BREAK,
127166
} from './language';
128167

168+
export type {
169+
Lexer,
170+
ParseOptions,
171+
172+
// AST nodes
173+
Location,
174+
Token,
175+
Node,
176+
Name,
177+
Document,
178+
Definition,
179+
OperationDefinition,
180+
OperationType,
181+
VariableDefinition,
182+
Variable,
183+
SelectionSet,
184+
Selection,
185+
Field,
186+
Argument,
187+
FragmentSpread,
188+
InlineFragment,
189+
FragmentDefinition,
190+
Value,
191+
IntValue,
192+
FloatValue,
193+
StringValue,
194+
BooleanValue,
195+
NullValue,
196+
EnumValue,
197+
ListValue,
198+
ObjectValue,
199+
ObjectField,
200+
Directive,
201+
Type,
202+
NamedType,
203+
ListType,
204+
NonNullType,
205+
TypeSystemDefinition,
206+
SchemaDefinition,
207+
OperationTypeDefinition,
208+
TypeDefinition,
209+
ScalarTypeDefinition,
210+
ObjectTypeDefinition,
211+
FieldDefinition,
212+
InputValueDefinition,
213+
InterfaceTypeDefinition,
214+
UnionTypeDefinition,
215+
EnumTypeDefinition,
216+
EnumValueDefinition,
217+
InputObjectTypeDefinition,
218+
TypeExtensionDefinition,
219+
DirectiveDefinition,
220+
} from './language';
221+
129222

130223
// Execute GraphQL queries.
131224
export {
132225
execute,
133226
} from './execution';
134227

228+
export type {
229+
ExecutionResult,
230+
} from './execute';
231+
135232

136233
// Validate GraphQL queries.
137234
export {
@@ -146,6 +243,11 @@ export {
146243
formatError,
147244
} from './error';
148245

246+
export type {
247+
GraphQLFormattedError,
248+
GraphQLErrorLocation,
249+
} from './error';
250+
149251

150252
// Utilities for operating on GraphQL type schema and parsed sources.
151253
export {
@@ -207,3 +309,25 @@ export {
207309
// Compares two GraphQLSchemas and detects breaking changes.
208310
findBreakingChanges,
209311
} from './utilities';
312+
313+
export type {
314+
BreakingChange,
315+
316+
IntrospectionDirective,
317+
IntrospectionEnumType,
318+
IntrospectionEnumValue,
319+
IntrospectionField,
320+
IntrospectionInputObjectType,
321+
IntrospectionInputValue,
322+
IntrospectionInterfaceType,
323+
IntrospectionListTypeRef,
324+
IntrospectionNamedTypeRef,
325+
IntrospectionNonNullTypeRef,
326+
IntrospectionObjectType,
327+
IntrospectionQuery,
328+
IntrospectionScalarType,
329+
IntrospectionSchema,
330+
IntrospectionType,
331+
IntrospectionTypeRef,
332+
IntrospectionUnionType,
333+
} from './introspectionQuery';

src/language/index.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,56 @@ export { parse, parseValue, parseType } from './parser';
1616
export { print } from './printer';
1717
export { Source } from './source';
1818
export { visit, visitInParallel, visitWithTypeInfo, BREAK } from './visitor';
19+
20+
export type { Lexer } from './lexer';
21+
export type { ParseOptions } from './parser';
22+
23+
export type {
24+
Location,
25+
Token,
26+
Node,
27+
Name,
28+
Document,
29+
Definition,
30+
OperationDefinition,
31+
OperationType,
32+
VariableDefinition,
33+
Variable,
34+
SelectionSet,
35+
Selection,
36+
Field,
37+
Argument,
38+
FragmentSpread,
39+
InlineFragment,
40+
FragmentDefinition,
41+
Value,
42+
IntValue,
43+
FloatValue,
44+
StringValue,
45+
BooleanValue,
46+
NullValue,
47+
EnumValue,
48+
ListValue,
49+
ObjectValue,
50+
ObjectField,
51+
Directive,
52+
Type,
53+
NamedType,
54+
ListType,
55+
NonNullType,
56+
TypeSystemDefinition,
57+
SchemaDefinition,
58+
OperationTypeDefinition,
59+
TypeDefinition,
60+
ScalarTypeDefinition,
61+
ObjectTypeDefinition,
62+
FieldDefinition,
63+
InputValueDefinition,
64+
InterfaceTypeDefinition,
65+
UnionTypeDefinition,
66+
EnumTypeDefinition,
67+
EnumValueDefinition,
68+
InputObjectTypeDefinition,
69+
TypeExtensionDefinition,
70+
DirectiveDefinition,
71+
} from './ast';

0 commit comments

Comments
 (0)