Skip to content

Commit c4098e1

Browse files
Flow: switch more types to be exact (#2269)
1 parent cadf66a commit c4098e1

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ rules:
2626
flowtype/no-unused-expressions: off
2727
flowtype/no-weak-types: [error, { any: false }]
2828
flowtype/require-compound-type-alias: off
29-
flowtype/require-exact-type: off # TODO
29+
flowtype/require-exact-type: off
3030
flowtype/require-indexer-name: error
3131
flowtype/require-inexact-type: off # checked by Flow
3232
flowtype/require-parameter-type: off

src/language/parser.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import {
6262
/**
6363
* Configuration options to control parser behavior
6464
*/
65-
export type ParseOptions = {
65+
export type ParseOptions = {|
6666
/**
6767
* By default, the parser creates AST nodes that know the location
6868
* in the source that they correspond to. This configuration flag
@@ -107,9 +107,7 @@ export type ParseOptions = {
107107
* future.
108108
*/
109109
experimentalFragmentVariables?: boolean,
110-
111-
...
112-
};
110+
|};
113111

114112
/**
115113
* Given a GraphQL source, parses it into a Document.
@@ -177,7 +175,12 @@ class Parser {
177175
);
178176

179177
this._lexer = new Lexer(sourceObj);
180-
this._options = options || {};
178+
this._options = options || {
179+
noLocation: false,
180+
allowLegacySDLEmptyFields: false,
181+
allowLegacySDLImplementsInterfaces: false,
182+
experimentalFragmentVariables: false,
183+
};
181184
}
182185

183186
/**

src/utilities/buildASTSchema.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import {
7575

7676
import { valueFromAST } from './valueFromAST';
7777

78-
export type BuildSchemaOptions = {
78+
export type BuildSchemaOptions = {|
7979
...GraphQLSchemaValidationOptions,
8080

8181
/**
@@ -94,9 +94,7 @@ export type BuildSchemaOptions = {
9494
* Default: false
9595
*/
9696
assumeValidSDL?: boolean,
97-
98-
...
99-
};
97+
|};
10098

10199
/**
102100
* This takes the ast of a schema document produced by the parse function in
@@ -525,7 +523,21 @@ function getLeadingCommentBlock(node): void | string {
525523
*/
526524
export function buildSchema(
527525
source: string | Source,
528-
options?: BuildSchemaOptions & ParseOptions,
526+
options?: {| ...BuildSchemaOptions, ...ParseOptions |},
529527
): GraphQLSchema {
530-
return buildASTSchema(parse(source, options), options);
528+
const document = parse(source, {
529+
noLocation: (options && options.noLocation) || false,
530+
allowLegacySDLEmptyFields:
531+
(options && options.allowLegacySDLEmptyFields) || false,
532+
allowLegacySDLImplementsInterfaces:
533+
(options && options.allowLegacySDLImplementsInterfaces) || false,
534+
experimentalFragmentVariables:
535+
(options && options.experimentalFragmentVariables) || false,
536+
});
537+
538+
return buildASTSchema(document, {
539+
commentDescriptions: (options && options.commentDescriptions) || false,
540+
assumeValidSDL: (options && options.assumeValidSDL) || false,
541+
assumeValid: (options && options.assumeValid) || false,
542+
});
531543
}

0 commit comments

Comments
 (0)