diff --git a/.eslintrc.yml b/.eslintrc.yml index 2475142063..306bc857d1 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -464,7 +464,7 @@ overrides: flowtype/no-unused-expressions: off flowtype/no-weak-types: [error, { any: false }] flowtype/require-compound-type-alias: off - flowtype/require-exact-type: off + flowtype/require-exact-type: [error, never] flowtype/require-indexer-name: error flowtype/require-inexact-type: off # checked by Flow flowtype/require-parameter-type: off diff --git a/.flowconfig b/.flowconfig index 56017b6aa8..519988aff5 100644 --- a/.flowconfig +++ b/.flowconfig @@ -5,10 +5,7 @@ [include] [lints] -sketchy-null-bool=error -sketchy-null-string=error -sketchy-null-number=error -sketchy-null-mixed=error +sketchy-null=error sketchy-number=error untyped-type-import=error nonstrict-import=off @@ -20,8 +17,8 @@ unsafe-getters-setters=error unnecessary-optional-chain=error unnecessary-invariant=error signature-verification-failure=error -implicit-inexact-object=error -ambiguous-object-type=error +implicit-inexact-object=off +ambiguous-object-type=off uninitialized-instance-property=error default-import-access=error invalid-import-star-use=error @@ -33,6 +30,7 @@ export-renamed-default=error [options] all=true module.use_strict=true +exact_by_default=true experimental.const_params=true include_warnings=true no_flowlib=true diff --git a/src/__testUtils__/__tests__/genFuzzStrings-test.js b/src/__testUtils__/__tests__/genFuzzStrings-test.js index c329123717..05077ca057 100644 --- a/src/__testUtils__/__tests__/genFuzzStrings-test.js +++ b/src/__testUtils__/__tests__/genFuzzStrings-test.js @@ -3,10 +3,10 @@ import { describe, it } from 'mocha'; import { genFuzzStrings } from '../genFuzzStrings'; -function expectFuzzStrings(options: {| +function expectFuzzStrings(options: { allowedChars: Array, maxLength: number, -|}) { +}) { return expect([...genFuzzStrings(options)]); } diff --git a/src/__testUtils__/genFuzzStrings.js b/src/__testUtils__/genFuzzStrings.js index 86aaf96709..9b44946440 100644 --- a/src/__testUtils__/genFuzzStrings.js +++ b/src/__testUtils__/genFuzzStrings.js @@ -1,10 +1,10 @@ /** * Generator that produces all possible combinations of allowed characters. */ -export function* genFuzzStrings(options: {| +export function* genFuzzStrings(options: { allowedChars: Array, maxLength: number, -|}): Generator { +}): Generator { const { allowedChars, maxLength } = options; const numAllowedChars = allowedChars.length; diff --git a/src/__tests__/starWarsData.js b/src/__tests__/starWarsData.js index 7e1917b8bd..45fed55edd 100644 --- a/src/__tests__/starWarsData.js +++ b/src/__tests__/starWarsData.js @@ -10,23 +10,23 @@ export type Character = { ... }; -export type Human = {| +export type Human = { type: 'Human', id: string, name: string, friends: Array, appearsIn: Array, homePlanet?: string, -|}; +}; -export type Droid = {| +export type Droid = { type: 'Droid', id: string, name: string, friends: Array, appearsIn: Array, primaryFunction: string, -|}; +}; /** * This defines a basic set of data for our Star Wars Schema. @@ -79,7 +79,7 @@ const tarkin: Human = { appearsIn: [4], }; -const humanData: {| [id: string]: Human |} = { +const humanData: { [id: string]: Human } = { [luke.id]: luke, [vader.id]: vader, [han.id]: han, @@ -105,7 +105,7 @@ const artoo: Droid = { primaryFunction: 'Astromech', }; -const droidData: {| [id: string]: Droid |} = { +const droidData: { [id: string]: Droid } = { [threepio.id]: threepio, [artoo.id]: artoo, }; diff --git a/src/error/formatError.js b/src/error/formatError.js index ef59ad8df8..520c7be76c 100644 --- a/src/error/formatError.js +++ b/src/error/formatError.js @@ -23,7 +23,7 @@ export function formatError(error: GraphQLError): GraphQLFormattedError { /** * @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors */ -export type GraphQLFormattedError = {| +export type GraphQLFormattedError = { /** * A short, human-readable summary of the problem that **SHOULD NOT** change * from occurrence to occurrence of the problem, except for purposes of @@ -47,4 +47,4 @@ export type GraphQLFormattedError = {| * and hence there are no additional restrictions on its contents. */ +extensions?: { [key: string]: mixed, ... }, -|}; +}; diff --git a/src/execution/__tests__/abstract-test.js b/src/execution/__tests__/abstract-test.js index 9409204edc..2d1423e002 100644 --- a/src/execution/__tests__/abstract-test.js +++ b/src/execution/__tests__/abstract-test.js @@ -17,11 +17,11 @@ import { buildSchema } from '../../utilities/buildASTSchema'; import { executeSync, execute } from '../execute'; -async function executeQuery(args: {| +async function executeQuery(args: { schema: GraphQLSchema, query: string, rootValue?: mixed, -|}) { +}) { const { schema, query, rootValue } = args; const document = parse(query); const result = executeSync({ @@ -534,7 +534,7 @@ describe('Execute: Handles execution of abstract types', () => { } `); - function expectError({ forTypeName }: {| forTypeName: mixed |}) { + function expectError({ forTypeName }: { forTypeName: mixed }) { const rootValue = { pet: { __typename: forTypeName } }; const result = executeSync({ schema, document, rootValue }); return { diff --git a/src/execution/__tests__/lists-test.js b/src/execution/__tests__/lists-test.js index 5654b55ccc..9d1215f483 100644 --- a/src/execution/__tests__/lists-test.js +++ b/src/execution/__tests__/lists-test.js @@ -65,7 +65,7 @@ describe('Execute: Accepts any iterable as list value', () => { }); describe('Execute: Handles list nullability', () => { - async function complete(args: {| listField: mixed, as: string |}) { + async function complete(args: { listField: mixed, as: string }) { const { listField, as } = args; const schema = buildSchema(`type Query { listField: ${as} }`); const document = parse('{ listField }'); diff --git a/src/execution/__tests__/resolve-test.js b/src/execution/__tests__/resolve-test.js index afe911e7bc..b8d28a615b 100644 --- a/src/execution/__tests__/resolve-test.js +++ b/src/execution/__tests__/resolve-test.js @@ -64,7 +64,7 @@ describe('Execute: resolve function', () => { this._num = num; } - test(args: {| addend1: number |}, context: {| addend2: number |}) { + test(args: { addend1: number }, context: { addend2: number }) { return this._num + args.addend1 + context.addend2; } } diff --git a/src/execution/execute.js b/src/execution/execute.js index 6f193c14c0..63e1536f6d 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -92,7 +92,7 @@ import { * Namely, schema of the type system that is currently executing, * and the fragments defined in the query document */ -export type ExecutionContext = {| +export type ExecutionContext = { schema: GraphQLSchema, fragments: ObjMap, rootValue: mixed, @@ -102,7 +102,7 @@ export type ExecutionContext = {| fieldResolver: GraphQLFieldResolver, typeResolver: GraphQLTypeResolver, errors: Array, -|}; +}; /** * The result of GraphQL execution. @@ -111,19 +111,19 @@ export type ExecutionContext = {| * - `data` is the result of a successful execution of the query. * - `extensions` is reserved for adding non-standard properties. */ -export type ExecutionResult = {| +export type ExecutionResult = { errors?: $ReadOnlyArray, data?: ObjMap | null, extensions?: ObjMap, -|}; +}; -export type FormattedExecutionResult = {| +export type FormattedExecutionResult = { errors?: $ReadOnlyArray, data?: ObjMap | null, extensions?: ObjMap, -|}; +}; -export type ExecutionArgs = {| +export type ExecutionArgs = { schema: GraphQLSchema, document: DocumentNode, rootValue?: mixed, @@ -132,7 +132,7 @@ export type ExecutionArgs = {| operationName?: ?string, fieldResolver?: ?GraphQLFieldResolver, typeResolver?: ?GraphQLTypeResolver, -|}; +}; /** * Implements the "Evaluating requests" section of the GraphQL specification. diff --git a/src/execution/values.js b/src/execution/values.js index 3b6728254b..781dc30bfc 100644 --- a/src/execution/values.js +++ b/src/execution/values.js @@ -23,8 +23,8 @@ import { valueFromAST } from '../utilities/valueFromAST'; import { coerceInputValue } from '../utilities/coerceInputValue'; type CoercedVariableValues = - | {| errors: $ReadOnlyArray |} - | {| coerced: { [variable: string]: mixed, ... } |}; + | { errors: $ReadOnlyArray } + | { coerced: { [variable: string]: mixed, ... } }; /** * Prepares an object map of variableValues of the correct type based on the @@ -41,7 +41,7 @@ export function getVariableValues( schema: GraphQLSchema, varDefNodes: $ReadOnlyArray, inputs: { +[variable: string]: mixed, ... }, - options?: {| maxErrors?: number |}, + options?: { maxErrors?: number }, ): CoercedVariableValues { const errors = []; const maxErrors = options?.maxErrors; diff --git a/src/graphql.js b/src/graphql.js index 3938b157bd..1aaf5e11bd 100644 --- a/src/graphql.js +++ b/src/graphql.js @@ -55,7 +55,7 @@ import { execute } from './execution/execute'; * If not provided, the default type resolver is used (which looks for a * `__typename` field or alternatively calls the `isTypeOf` method). */ -export type GraphQLArgs = {| +export type GraphQLArgs = { schema: GraphQLSchema, source: string | Source, rootValue?: mixed, @@ -64,7 +64,7 @@ export type GraphQLArgs = {| operationName?: ?string, fieldResolver?: ?GraphQLFieldResolver, typeResolver?: ?GraphQLTypeResolver, -|}; +}; export function graphql(args: GraphQLArgs): Promise { // Always return a Promise for a consistent API. diff --git a/src/jsutils/Path.js b/src/jsutils/Path.js index 47e8c7693c..f7888ae027 100644 --- a/src/jsutils/Path.js +++ b/src/jsutils/Path.js @@ -1,8 +1,8 @@ -export type Path = {| +export type Path = { +prev: Path | void, +key: string | number, +typename: string | void, -|}; +}; /** * Given a Path and a key, return a new Path containing the new key. diff --git a/src/language/__tests__/source-test.js b/src/language/__tests__/source-test.js index 31a34aa16d..1ea59c506d 100644 --- a/src/language/__tests__/source-test.js +++ b/src/language/__tests__/source-test.js @@ -25,7 +25,7 @@ describe('Source', () => { }); it('rejects invalid locationOffset', () => { - function createSource(locationOffset: {| line: number, column: number |}) { + function createSource(locationOffset: { line: number, column: number }) { return new Source('', '', locationOffset); } diff --git a/src/language/ast.js b/src/language/ast.js index f4de32054d..4f560ed5db 100644 --- a/src/language/ast.js +++ b/src/language/ast.js @@ -39,7 +39,7 @@ export class Location { this.source = source; } - toJSON(): {| start: number, end: number |} { + toJSON(): { start: number, end: number } { return { start: this.start, end: this.end }; } } @@ -106,12 +106,12 @@ export class Token { this.next = null; } - toJSON(): {| + toJSON(): { kind: TokenKindEnum, value: string | void, line: number, column: number, - |} { + } { return { kind: this.kind, value: this.value, @@ -179,7 +179,7 @@ export type ASTNode = /** * Utility type listing all nodes indexed by their kind. */ -export type ASTKindToNode = {| +export type ASTKindToNode = { Name: NameNode, Document: DocumentNode, OperationDefinition: OperationDefinitionNode, @@ -223,23 +223,23 @@ export type ASTKindToNode = {| UnionTypeExtension: UnionTypeExtensionNode, EnumTypeExtension: EnumTypeExtensionNode, InputObjectTypeExtension: InputObjectTypeExtensionNode, -|}; +}; // Name -export type NameNode = {| +export type NameNode = { +kind: 'Name', +loc?: Location, +value: string, -|}; +}; // Document -export type DocumentNode = {| +export type DocumentNode = { +kind: 'Document', +loc?: Location, +definitions: $ReadOnlyArray, -|}; +}; export type DefinitionNode = | ExecutableDefinitionNode @@ -250,7 +250,7 @@ export type ExecutableDefinitionNode = | OperationDefinitionNode | FragmentDefinitionNode; -export type OperationDefinitionNode = {| +export type OperationDefinitionNode = { +kind: 'OperationDefinition', +loc?: Location, +operation: OperationTypeNode, @@ -258,34 +258,34 @@ export type OperationDefinitionNode = {| +variableDefinitions?: $ReadOnlyArray, +directives?: $ReadOnlyArray, +selectionSet: SelectionSetNode, -|}; +}; export type OperationTypeNode = 'query' | 'mutation' | 'subscription'; -export type VariableDefinitionNode = {| +export type VariableDefinitionNode = { +kind: 'VariableDefinition', +loc?: Location, +variable: VariableNode, +type: TypeNode, +defaultValue?: ConstValueNode, +directives?: $ReadOnlyArray, -|}; +}; -export type VariableNode = {| +export type VariableNode = { +kind: 'Variable', +loc?: Location, +name: NameNode, -|}; +}; -export type SelectionSetNode = {| +export type SelectionSetNode = { kind: 'SelectionSet', loc?: Location, selections: $ReadOnlyArray, -|}; +}; export type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode; -export type FieldNode = {| +export type FieldNode = { +kind: 'Field', +loc?: Location, +alias?: NameNode, @@ -293,40 +293,40 @@ export type FieldNode = {| +arguments?: $ReadOnlyArray, +directives?: $ReadOnlyArray, +selectionSet?: SelectionSetNode, -|}; +}; -export type ArgumentNode = {| +export type ArgumentNode = { +kind: 'Argument', +loc?: Location, +name: NameNode, +value: ValueNode, -|}; +}; -export type ConstArgumentNode = {| +export type ConstArgumentNode = { +kind: 'Argument', +loc?: Location, +name: NameNode, +value: ConstValueNode, -|}; +}; // Fragments -export type FragmentSpreadNode = {| +export type FragmentSpreadNode = { +kind: 'FragmentSpread', +loc?: Location, +name: NameNode, +directives?: $ReadOnlyArray, -|}; +}; -export type InlineFragmentNode = {| +export type InlineFragmentNode = { +kind: 'InlineFragment', +loc?: Location, +typeCondition?: NamedTypeNode, +directives?: $ReadOnlyArray, +selectionSet: SelectionSetNode, -|}; +}; -export type FragmentDefinitionNode = {| +export type FragmentDefinitionNode = { +kind: 'FragmentDefinition', +loc?: Location, +name: NameNode, @@ -335,7 +335,7 @@ export type FragmentDefinitionNode = {| +typeCondition: NamedTypeNode, +directives?: $ReadOnlyArray, +selectionSet: SelectionSetNode, -|}; +}; // Values @@ -360,117 +360,117 @@ export type ConstValueNode = | ConstListValueNode | ConstObjectValueNode; -export type IntValueNode = {| +export type IntValueNode = { +kind: 'IntValue', +loc?: Location, +value: string, -|}; +}; -export type FloatValueNode = {| +export type FloatValueNode = { +kind: 'FloatValue', +loc?: Location, +value: string, -|}; +}; -export type StringValueNode = {| +export type StringValueNode = { +kind: 'StringValue', +loc?: Location, +value: string, +block?: boolean, -|}; +}; -export type BooleanValueNode = {| +export type BooleanValueNode = { +kind: 'BooleanValue', +loc?: Location, +value: boolean, -|}; +}; -export type NullValueNode = {| +export type NullValueNode = { +kind: 'NullValue', +loc?: Location, -|}; +}; -export type EnumValueNode = {| +export type EnumValueNode = { +kind: 'EnumValue', +loc?: Location, +value: string, -|}; +}; -export type ListValueNode = {| +export type ListValueNode = { +kind: 'ListValue', +loc?: Location, +values: $ReadOnlyArray, -|}; +}; -export type ConstListValueNode = {| +export type ConstListValueNode = { +kind: 'ListValue', +loc?: Location, +values: $ReadOnlyArray, -|}; +}; -export type ObjectValueNode = {| +export type ObjectValueNode = { +kind: 'ObjectValue', +loc?: Location, +fields: $ReadOnlyArray, -|}; +}; -export type ConstObjectValueNode = {| +export type ConstObjectValueNode = { +kind: 'ObjectValue', +loc?: Location, +fields: $ReadOnlyArray, -|}; +}; -export type ObjectFieldNode = {| +export type ObjectFieldNode = { +kind: 'ObjectField', +loc?: Location, +name: NameNode, +value: ValueNode, -|}; +}; -export type ConstObjectFieldNode = {| +export type ConstObjectFieldNode = { +kind: 'ObjectField', +loc?: Location, +name: NameNode, +value: ConstValueNode, -|}; +}; // Directives -export type DirectiveNode = {| +export type DirectiveNode = { +kind: 'Directive', +loc?: Location, +name: NameNode, +arguments?: $ReadOnlyArray, -|}; +}; -export type ConstDirectiveNode = {| +export type ConstDirectiveNode = { +kind: 'Directive', +loc?: Location, +name: NameNode, +arguments?: $ReadOnlyArray, -|}; +}; // Type Reference export type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode; -export type NamedTypeNode = {| +export type NamedTypeNode = { +kind: 'NamedType', +loc?: Location, +name: NameNode, -|}; +}; -export type ListTypeNode = {| +export type ListTypeNode = { +kind: 'ListType', +loc?: Location, +type: TypeNode, -|}; +}; -export type NonNullTypeNode = {| +export type NonNullTypeNode = { +kind: 'NonNullType', +loc?: Location, +type: NamedTypeNode | ListTypeNode, -|}; +}; // Type System Definition @@ -479,20 +479,20 @@ export type TypeSystemDefinitionNode = | TypeDefinitionNode | DirectiveDefinitionNode; -export type SchemaDefinitionNode = {| +export type SchemaDefinitionNode = { +kind: 'SchemaDefinition', +loc?: Location, +description?: StringValueNode, +directives?: $ReadOnlyArray, +operationTypes: $ReadOnlyArray, -|}; +}; -export type OperationTypeDefinitionNode = {| +export type OperationTypeDefinitionNode = { +kind: 'OperationTypeDefinition', +loc?: Location, +operation: OperationTypeNode, +type: NamedTypeNode, -|}; +}; // Type Definition @@ -504,15 +504,15 @@ export type TypeDefinitionNode = | EnumTypeDefinitionNode | InputObjectTypeDefinitionNode; -export type ScalarTypeDefinitionNode = {| +export type ScalarTypeDefinitionNode = { +kind: 'ScalarTypeDefinition', +loc?: Location, +description?: StringValueNode, +name: NameNode, +directives?: $ReadOnlyArray, -|}; +}; -export type ObjectTypeDefinitionNode = {| +export type ObjectTypeDefinitionNode = { +kind: 'ObjectTypeDefinition', +loc?: Location, +description?: StringValueNode, @@ -520,9 +520,9 @@ export type ObjectTypeDefinitionNode = {| +interfaces?: $ReadOnlyArray, +directives?: $ReadOnlyArray, +fields?: $ReadOnlyArray, -|}; +}; -export type FieldDefinitionNode = {| +export type FieldDefinitionNode = { +kind: 'FieldDefinition', +loc?: Location, +description?: StringValueNode, @@ -530,9 +530,9 @@ export type FieldDefinitionNode = {| +arguments?: $ReadOnlyArray, +type: TypeNode, +directives?: $ReadOnlyArray, -|}; +}; -export type InputValueDefinitionNode = {| +export type InputValueDefinitionNode = { +kind: 'InputValueDefinition', +loc?: Location, +description?: StringValueNode, @@ -540,9 +540,9 @@ export type InputValueDefinitionNode = {| +type: TypeNode, +defaultValue?: ConstValueNode, +directives?: $ReadOnlyArray, -|}; +}; -export type InterfaceTypeDefinitionNode = {| +export type InterfaceTypeDefinitionNode = { +kind: 'InterfaceTypeDefinition', +loc?: Location, +description?: StringValueNode, @@ -550,46 +550,46 @@ export type InterfaceTypeDefinitionNode = {| +interfaces?: $ReadOnlyArray, +directives?: $ReadOnlyArray, +fields?: $ReadOnlyArray, -|}; +}; -export type UnionTypeDefinitionNode = {| +export type UnionTypeDefinitionNode = { +kind: 'UnionTypeDefinition', +loc?: Location, +description?: StringValueNode, +name: NameNode, +directives?: $ReadOnlyArray, +types?: $ReadOnlyArray, -|}; +}; -export type EnumTypeDefinitionNode = {| +export type EnumTypeDefinitionNode = { +kind: 'EnumTypeDefinition', +loc?: Location, +description?: StringValueNode, +name: NameNode, +directives?: $ReadOnlyArray, +values?: $ReadOnlyArray, -|}; +}; -export type EnumValueDefinitionNode = {| +export type EnumValueDefinitionNode = { +kind: 'EnumValueDefinition', +loc?: Location, +description?: StringValueNode, +name: NameNode, +directives?: $ReadOnlyArray, -|}; +}; -export type InputObjectTypeDefinitionNode = {| +export type InputObjectTypeDefinitionNode = { +kind: 'InputObjectTypeDefinition', +loc?: Location, +description?: StringValueNode, +name: NameNode, +directives?: $ReadOnlyArray, +fields?: $ReadOnlyArray, -|}; +}; // Directive Definitions -export type DirectiveDefinitionNode = {| +export type DirectiveDefinitionNode = { +kind: 'DirectiveDefinition', +loc?: Location, +description?: StringValueNode, @@ -597,18 +597,18 @@ export type DirectiveDefinitionNode = {| +arguments?: $ReadOnlyArray, +repeatable: boolean, +locations: $ReadOnlyArray, -|}; +}; // Type System Extensions export type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode; -export type SchemaExtensionNode = {| +export type SchemaExtensionNode = { +kind: 'SchemaExtension', +loc?: Location, +directives?: $ReadOnlyArray, +operationTypes?: $ReadOnlyArray, -|}; +}; // Type Extensions @@ -620,51 +620,51 @@ export type TypeExtensionNode = | EnumTypeExtensionNode | InputObjectTypeExtensionNode; -export type ScalarTypeExtensionNode = {| +export type ScalarTypeExtensionNode = { +kind: 'ScalarTypeExtension', +loc?: Location, +name: NameNode, +directives?: $ReadOnlyArray, -|}; +}; -export type ObjectTypeExtensionNode = {| +export type ObjectTypeExtensionNode = { +kind: 'ObjectTypeExtension', +loc?: Location, +name: NameNode, +interfaces?: $ReadOnlyArray, +directives?: $ReadOnlyArray, +fields?: $ReadOnlyArray, -|}; +}; -export type InterfaceTypeExtensionNode = {| +export type InterfaceTypeExtensionNode = { +kind: 'InterfaceTypeExtension', +loc?: Location, +name: NameNode, +interfaces?: $ReadOnlyArray, +directives?: $ReadOnlyArray, +fields?: $ReadOnlyArray, -|}; +}; -export type UnionTypeExtensionNode = {| +export type UnionTypeExtensionNode = { +kind: 'UnionTypeExtension', +loc?: Location, +name: NameNode, +directives?: $ReadOnlyArray, +types?: $ReadOnlyArray, -|}; +}; -export type EnumTypeExtensionNode = {| +export type EnumTypeExtensionNode = { +kind: 'EnumTypeExtension', +loc?: Location, +name: NameNode, +directives?: $ReadOnlyArray, +values?: $ReadOnlyArray, -|}; +}; -export type InputObjectTypeExtensionNode = {| +export type InputObjectTypeExtensionNode = { +kind: 'InputObjectTypeExtension', +loc?: Location, +name: NameNode, +directives?: $ReadOnlyArray, +fields?: $ReadOnlyArray, -|}; +}; diff --git a/src/language/location.js b/src/language/location.js index 8da175d4f2..4695d52e71 100644 --- a/src/language/location.js +++ b/src/language/location.js @@ -3,10 +3,10 @@ import type { Source } from './source'; /** * Represents a location in a Source. */ -export type SourceLocation = {| +export type SourceLocation = { +line: number, +column: number, -|}; +}; /** * Takes a Source and a UTF-8 character offset, and returns the corresponding diff --git a/src/language/parser.js b/src/language/parser.js index a2b5a0b0b7..9205382228 100644 --- a/src/language/parser.js +++ b/src/language/parser.js @@ -61,7 +61,7 @@ import { Lexer, isPunctuatorTokenKind } from './lexer'; /** * Configuration options to control parser behavior */ -export type ParseOptions = {| +export type ParseOptions = { /** * By default, the parser creates AST nodes that know the location * in the source that they correspond to. This configuration flag @@ -84,7 +84,7 @@ export type ParseOptions = {| * */ allowLegacyFragmentVariables?: boolean, -|}; +}; /** * Given a GraphQL source, parses it into a Document. diff --git a/src/language/source.js b/src/language/source.js index dd4837ce06..a3bfd14f92 100644 --- a/src/language/source.js +++ b/src/language/source.js @@ -2,10 +2,10 @@ import { inspect } from '../jsutils/inspect'; import { devAssert } from '../jsutils/devAssert'; import { instanceOf } from '../jsutils/instanceOf'; -type Location = {| +type Location = { line: number, column: number, -|}; +}; /** * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are diff --git a/src/language/visitor.js b/src/language/visitor.js index 0c241d5dd5..c6d7d3c242 100644 --- a/src/language/visitor.js +++ b/src/language/visitor.js @@ -14,10 +14,10 @@ type KindVisitor = $ObjMap< (node: Node) => ASTVisitFn | EnterLeaveVisitor, >; -type EnterLeaveVisitor = {| +type EnterLeaveVisitor = { +enter?: ASTVisitFn, +leave?: ASTVisitFn, -|}; +}; /** * A visitor is comprised of visit functions, which are called on each node diff --git a/src/subscription/__tests__/subscribe-test.js b/src/subscription/__tests__/subscribe-test.js index e9e242fe65..c5810f862e 100644 --- a/src/subscription/__tests__/subscribe-test.js +++ b/src/subscription/__tests__/subscribe-test.js @@ -16,12 +16,12 @@ import { createSourceEventStream, subscribe } from '../subscribe'; import { SimplePubSub } from './simplePubSub'; -type Email = {| +type Email = { from: string, subject: string, message: string, unread: boolean, -|}; +}; const EmailType = new GraphQLObjectType({ name: 'Email', diff --git a/src/subscription/subscribe.js b/src/subscription/subscribe.js index 559b1a6ccc..b9a2d63bfb 100644 --- a/src/subscription/subscribe.js +++ b/src/subscription/subscribe.js @@ -25,7 +25,7 @@ import { getOperationRootType } from '../utilities/getOperationRootType'; import { mapAsyncIterator } from './mapAsyncIterator'; -export type SubscriptionArgs = {| +export type SubscriptionArgs = { schema: GraphQLSchema, document: DocumentNode, rootValue?: mixed, @@ -34,7 +34,7 @@ export type SubscriptionArgs = {| operationName?: ?string, fieldResolver?: ?GraphQLFieldResolver, subscribeFieldResolver?: ?GraphQLFieldResolver, -|}; +}; /** * Implements the "Subscribe" algorithm described in the GraphQL specification. diff --git a/src/type/__tests__/predicate-test.js b/src/type/__tests__/predicate-test.js index f94bed1030..9c011a240c 100644 --- a/src/type/__tests__/predicate-test.js +++ b/src/type/__tests__/predicate-test.js @@ -563,10 +563,10 @@ describe('Type predicates', () => { }); describe('isRequiredArgument', () => { - function buildArg(config: {| + function buildArg(config: { type: GraphQLInputType, defaultValue?: mixed, - |}): GraphQLArgument { + }): GraphQLArgument { return { name: 'someArg', type: config.type, @@ -611,10 +611,10 @@ describe('Type predicates', () => { }); describe('isRequiredInputField', () => { - function buildInputField(config: {| + function buildInputField(config: { type: GraphQLInputType, defaultValue?: mixed, - |}): GraphQLInputField { + }): GraphQLInputField { return { name: 'someInputField', type: config.type, diff --git a/src/type/definition.js b/src/type/definition.js index 7abdc25b0a..2aca26f56b 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -643,7 +643,7 @@ export type GraphQLScalarLiteralParser = ( variables: ?ObjMap, ) => ?TInternal; -export type GraphQLScalarTypeConfig = {| +export type GraphQLScalarTypeConfig = { name: string, description?: ?string, specifiedByURL?: ?string, @@ -656,16 +656,16 @@ export type GraphQLScalarTypeConfig = {| extensions?: ?ReadOnlyObjMapLike, astNode?: ?ScalarTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -|}; +}; -type GraphQLScalarTypeNormalizedConfig = {| +type GraphQLScalarTypeNormalizedConfig = { ...GraphQLScalarTypeConfig, serialize: GraphQLScalarSerializer, parseValue: GraphQLScalarValueParser, parseLiteral: GraphQLScalarLiteralParser, extensions: ?ReadOnlyObjMap, extensionASTNodes: $ReadOnlyArray, -|}; +}; /** * Object Type Definition @@ -884,7 +884,7 @@ export function argsToArgsConfig( ); } -export type GraphQLObjectTypeConfig = {| +export type GraphQLObjectTypeConfig = { name: string, description?: ?string, interfaces?: ThunkArray, @@ -893,15 +893,15 @@ export type GraphQLObjectTypeConfig = {| extensions?: ?ReadOnlyObjMapLike, astNode?: ?ObjectTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -|}; +}; -type GraphQLObjectTypeNormalizedConfig = {| +type GraphQLObjectTypeNormalizedConfig = { ...GraphQLObjectTypeConfig, interfaces: Array, fields: GraphQLFieldConfigMap, extensions: ?ReadOnlyObjMap, extensionASTNodes: $ReadOnlyArray, -|}; +}; /** * Note: returning GraphQLObjectType is deprecated and will be removed in v16.0.0 @@ -930,7 +930,7 @@ export type GraphQLFieldResolver< info: GraphQLResolveInfo, ) => mixed; -export type GraphQLResolveInfo = {| +export type GraphQLResolveInfo = { +fieldName: string, +fieldNodes: $ReadOnlyArray, +returnType: GraphQLOutputType, @@ -941,13 +941,13 @@ export type GraphQLResolveInfo = {| +rootValue: mixed, +operation: OperationDefinitionNode, +variableValues: { [variable: string]: mixed, ... }, -|}; +}; export type GraphQLFieldConfig< TSource, TContext, TArgs = { [argument: string]: any, ... }, -> = {| +> = { description?: ?string, type: GraphQLOutputType, args?: GraphQLFieldConfigArgumentMap, @@ -956,18 +956,18 @@ export type GraphQLFieldConfig< deprecationReason?: ?string, extensions?: ?ReadOnlyObjMapLike, astNode?: ?FieldDefinitionNode, -|}; +}; export type GraphQLFieldConfigArgumentMap = ObjMap; -export type GraphQLArgumentConfig = {| +export type GraphQLArgumentConfig = { description?: ?string, type: GraphQLInputType, defaultValue?: mixed, extensions?: ?ReadOnlyObjMapLike, deprecationReason?: ?string, astNode?: ?InputValueDefinitionNode, -|}; +}; export type GraphQLFieldConfigMap = ObjMap< GraphQLFieldConfig, @@ -977,7 +977,7 @@ export type GraphQLField< TSource, TContext, TArgs = { [argument: string]: any, ... }, -> = {| +> = { name: string, description: ?string, type: GraphQLOutputType, @@ -987,9 +987,9 @@ export type GraphQLField< deprecationReason: ?string, extensions: ?ReadOnlyObjMap, astNode: ?FieldDefinitionNode, -|}; +}; -export type GraphQLArgument = {| +export type GraphQLArgument = { name: string, description: ?string, type: GraphQLInputType, @@ -997,7 +997,7 @@ export type GraphQLArgument = {| deprecationReason: ?string, extensions: ?ReadOnlyObjMap, astNode: ?InputValueDefinitionNode, -|}; +}; export function isRequiredArgument(arg: GraphQLArgument): boolean %checks { return isNonNullType(arg.type) && arg.defaultValue === undefined; @@ -1095,7 +1095,7 @@ export class GraphQLInterfaceType { } } -export type GraphQLInterfaceTypeConfig = {| +export type GraphQLInterfaceTypeConfig = { name: string, description?: ?string, interfaces?: ThunkArray, @@ -1109,15 +1109,15 @@ export type GraphQLInterfaceTypeConfig = {| extensions?: ?ReadOnlyObjMapLike, astNode?: ?InterfaceTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -|}; +}; -export type GraphQLInterfaceTypeNormalizedConfig = {| +export type GraphQLInterfaceTypeNormalizedConfig = { ...GraphQLInterfaceTypeConfig, interfaces: Array, fields: GraphQLFieldConfigMap, extensions: ?ReadOnlyObjMap, extensionASTNodes: $ReadOnlyArray, -|}; +}; /** * Union Type Definition @@ -1213,7 +1213,7 @@ function defineTypes( return types; } -export type GraphQLUnionTypeConfig = {| +export type GraphQLUnionTypeConfig = { name: string, description?: ?string, types: ThunkArray, @@ -1226,14 +1226,14 @@ export type GraphQLUnionTypeConfig = {| extensions?: ?ReadOnlyObjMapLike, astNode?: ?UnionTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -|}; +}; -type GraphQLUnionTypeNormalizedConfig = {| +type GraphQLUnionTypeNormalizedConfig = { ...GraphQLUnionTypeConfig, types: Array, extensions: ?ReadOnlyObjMap, extensionASTNodes: $ReadOnlyArray, -|}; +}; /** * Enum Type Definition @@ -1415,39 +1415,39 @@ function defineEnumValues( }); } -export type GraphQLEnumTypeConfig /* */ = {| +export type GraphQLEnumTypeConfig /* */ = { name: string, description?: ?string, values: GraphQLEnumValueConfigMap /* */, extensions?: ?ReadOnlyObjMapLike, astNode?: ?EnumTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -|}; +}; -type GraphQLEnumTypeNormalizedConfig = {| +type GraphQLEnumTypeNormalizedConfig = { ...GraphQLEnumTypeConfig, extensions: ?ReadOnlyObjMap, extensionASTNodes: $ReadOnlyArray, -|}; +}; export type GraphQLEnumValueConfigMap /* */ = ObjMap */>; -export type GraphQLEnumValueConfig /* */ = {| +export type GraphQLEnumValueConfig /* */ = { description?: ?string, value?: any /* T */, deprecationReason?: ?string, extensions?: ?ReadOnlyObjMapLike, astNode?: ?EnumValueDefinitionNode, -|}; +}; -export type GraphQLEnumValue /* */ = {| +export type GraphQLEnumValue /* */ = { name: string, description: ?string, value: any /* T */, deprecationReason: ?string, extensions: ?ReadOnlyObjMap, astNode: ?EnumValueDefinitionNode, -|}; +}; /** * Input Object Type Definition @@ -1555,34 +1555,34 @@ function defineInputFieldMap( }); } -export type GraphQLInputObjectTypeConfig = {| +export type GraphQLInputObjectTypeConfig = { name: string, description?: ?string, fields: ThunkObjMap, extensions?: ?ReadOnlyObjMapLike, astNode?: ?InputObjectTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -|}; +}; -type GraphQLInputObjectTypeNormalizedConfig = {| +type GraphQLInputObjectTypeNormalizedConfig = { ...GraphQLInputObjectTypeConfig, fields: GraphQLInputFieldConfigMap, extensions: ?ReadOnlyObjMap, extensionASTNodes: $ReadOnlyArray, -|}; +}; -export type GraphQLInputFieldConfig = {| +export type GraphQLInputFieldConfig = { description?: ?string, type: GraphQLInputType, defaultValue?: mixed, deprecationReason?: ?string, extensions?: ?ReadOnlyObjMapLike, astNode?: ?InputValueDefinitionNode, -|}; +}; export type GraphQLInputFieldConfigMap = ObjMap; -export type GraphQLInputField = {| +export type GraphQLInputField = { name: string, description: ?string, type: GraphQLInputType, @@ -1590,7 +1590,7 @@ export type GraphQLInputField = {| deprecationReason: ?string, extensions: ?ReadOnlyObjMap, astNode: ?InputValueDefinitionNode, -|}; +}; export function isRequiredInputField( field: GraphQLInputField, diff --git a/src/type/directives.js b/src/type/directives.js index a6ca5005c9..ee1f6389d0 100644 --- a/src/type/directives.js +++ b/src/type/directives.js @@ -102,7 +102,7 @@ export class GraphQLDirective { } } -export type GraphQLDirectiveConfig = {| +export type GraphQLDirectiveConfig = { name: string, description?: ?string, locations: Array, @@ -110,14 +110,14 @@ export type GraphQLDirectiveConfig = {| isRepeatable?: ?boolean, extensions?: ?ReadOnlyObjMapLike, astNode?: ?DirectiveDefinitionNode, -|}; +}; -type GraphQLDirectiveNormalizedConfig = {| +type GraphQLDirectiveNormalizedConfig = { ...GraphQLDirectiveConfig, args: GraphQLFieldConfigArgumentMap, isRepeatable: boolean, extensions: ?ReadOnlyObjMap, -|}; +}; /** * Used to conditionally include fields or fragments. diff --git a/src/type/schema.js b/src/type/schema.js index 3f9c34a951..9a1fa96cc8 100644 --- a/src/type/schema.js +++ b/src/type/schema.js @@ -129,10 +129,10 @@ export class GraphQLSchema { _directives: $ReadOnlyArray; _typeMap: TypeMap; _subTypeMap: ObjMap>; - _implementationsMap: ObjMap<{| + _implementationsMap: ObjMap<{ objects: Array, interfaces: Array, - |}>; + }>; // Used as a cache for validateSchema(). __validationErrors: ?$ReadOnlyArray; @@ -284,10 +284,10 @@ export class GraphQLSchema { getImplementations( interfaceType: GraphQLInterfaceType, - ): {| + ): { objects: /* $ReadOnly */ Array, interfaces: /* $ReadOnly */ Array, - |} { + } { const implementations = this._implementationsMap[interfaceType.name]; return implementations ?? { objects: [], interfaces: [] }; } @@ -350,7 +350,7 @@ export class GraphQLSchema { type TypeMap = ObjMap; -export type GraphQLSchemaValidationOptions = {| +export type GraphQLSchemaValidationOptions = { /** * When building a schema from a GraphQL service's introspection result, it * might be safe to assume the schema is valid. Set to true to assume the @@ -359,9 +359,9 @@ export type GraphQLSchemaValidationOptions = {| * Default: false */ assumeValid?: boolean, -|}; +}; -export type GraphQLSchemaConfig = {| +export type GraphQLSchemaConfig = { description?: ?string, query?: ?GraphQLObjectType, mutation?: ?GraphQLObjectType, @@ -372,12 +372,12 @@ export type GraphQLSchemaConfig = {| astNode?: ?SchemaDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, ...GraphQLSchemaValidationOptions, -|}; +}; /** * @internal */ -export type GraphQLSchemaNormalizedConfig = {| +export type GraphQLSchemaNormalizedConfig = { ...GraphQLSchemaConfig, description: ?string, types: Array, @@ -385,7 +385,7 @@ export type GraphQLSchemaNormalizedConfig = {| extensions: ?ReadOnlyObjMap, extensionASTNodes: $ReadOnlyArray, assumeValid: boolean, -|}; +}; function collectReferencedTypes( type: GraphQLType, diff --git a/src/utilities/__tests__/coerceInputValue-test.js b/src/utilities/__tests__/coerceInputValue-test.js index a5aa72096c..978297c3b1 100644 --- a/src/utilities/__tests__/coerceInputValue-test.js +++ b/src/utilities/__tests__/coerceInputValue-test.js @@ -15,14 +15,14 @@ import { import { coerceInputValue } from '../coerceInputValue'; -type CoerceResult = {| +type CoerceResult = { value: mixed, - errors: $ReadOnlyArray<{| + errors: $ReadOnlyArray<{ path: $ReadOnlyArray, value: mixed, error: string, - |}>, -|}; + }>, +}; function coerceValue(inputValue: mixed, type: GraphQLInputType): CoerceResult { const errors = []; diff --git a/src/utilities/buildASTSchema.js b/src/utilities/buildASTSchema.js index aa2624b3bf..d6e56a4bf2 100644 --- a/src/utilities/buildASTSchema.js +++ b/src/utilities/buildASTSchema.js @@ -14,7 +14,7 @@ import { specifiedDirectives } from '../type/directives'; import { extendSchemaImpl } from './extendSchema'; -export type BuildSchemaOptions = {| +export type BuildSchemaOptions = { ...GraphQLSchemaValidationOptions, /** @@ -23,7 +23,7 @@ export type BuildSchemaOptions = {| * Default: false */ assumeValidSDL?: boolean, -|}; +}; /** * This takes the ast of a schema document produced by the parse function in @@ -97,7 +97,7 @@ export function buildASTSchema( */ export function buildSchema( source: string | Source, - options?: {| ...BuildSchemaOptions, ...ParseOptions |}, + options?: { ...BuildSchemaOptions, ...ParseOptions }, ): GraphQLSchema { const document = parse(source, { noLocation: options?.noLocation, diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index 4aeac58584..dcc46438c6 100644 --- a/src/utilities/extendSchema.js +++ b/src/utilities/extendSchema.js @@ -81,7 +81,7 @@ import { import { valueFromAST } from './valueFromAST'; -type Options = {| +type Options = { ...GraphQLSchemaValidationOptions, /** @@ -90,7 +90,7 @@ type Options = {| * Default: false */ assumeValidSDL?: boolean, -|}; +}; /** * Produces a new schema given an existing schema and a document which may @@ -393,11 +393,11 @@ export function extendSchemaImpl( function getOperationTypes( nodes: $ReadOnlyArray, - ): {| + ): { query: ?GraphQLObjectType, mutation: ?GraphQLObjectType, subscription: ?GraphQLObjectType, - |} { + } { const opTypes = {}; for (const node of nodes) { // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203') diff --git a/src/utilities/findBreakingChanges.js b/src/utilities/findBreakingChanges.js index d259d3b510..03e9933fcd 100644 --- a/src/utilities/findBreakingChanges.js +++ b/src/utilities/findBreakingChanges.js @@ -63,15 +63,15 @@ export const DangerousChangeType = Object.freeze({ ARG_DEFAULT_VALUE_CHANGE: 'ARG_DEFAULT_VALUE_CHANGE', }); -export type BreakingChange = {| +export type BreakingChange = { type: $Keys, description: string, -|}; +}; -export type DangerousChange = {| +export type DangerousChange = { type: $Keys, description: string, -|}; +}; /** * Given two schemas, returns an Array containing descriptions of all the types @@ -556,11 +556,11 @@ function stringifyValue(value: mixed, type: GraphQLInputType): string { function diff( oldArray: $ReadOnlyArray, newArray: $ReadOnlyArray, -): {| +): { added: Array, removed: Array, persisted: Array<[T, T]>, -|} { +} { const added = []; const removed = []; const persisted = []; diff --git a/src/utilities/getIntrospectionQuery.js b/src/utilities/getIntrospectionQuery.js index 888f964ff8..7b4bfad122 100644 --- a/src/utilities/getIntrospectionQuery.js +++ b/src/utilities/getIntrospectionQuery.js @@ -1,6 +1,6 @@ import type { DirectiveLocationEnum } from '../language/directiveLocation'; -export type IntrospectionOptions = {| +export type IntrospectionOptions = { // Whether to include descriptions in the introspection result. // Default: true descriptions?: boolean, @@ -20,7 +20,7 @@ export type IntrospectionOptions = {| // Whether target GraphQL server support deprecation of input values. // Default: false inputValueDeprecation?: boolean, -|}; +}; export function getIntrospectionQuery(options?: IntrospectionOptions): string { const optionsWithDefault = { @@ -147,18 +147,18 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string { `; } -export type IntrospectionQuery = {| +export type IntrospectionQuery = { +__schema: IntrospectionSchema, -|}; +}; -export type IntrospectionSchema = {| +export type IntrospectionSchema = { +description?: ?string, +queryType: IntrospectionNamedTypeRef, +mutationType: ?IntrospectionNamedTypeRef, +subscriptionType: ?IntrospectionNamedTypeRef, +types: $ReadOnlyArray, +directives: $ReadOnlyArray, -|}; +}; export type IntrospectionType = | IntrospectionScalarType @@ -180,14 +180,14 @@ export type IntrospectionInputType = | IntrospectionEnumType | IntrospectionInputObjectType; -export type IntrospectionScalarType = {| +export type IntrospectionScalarType = { +kind: 'SCALAR', +name: string, +description?: ?string, +specifiedByURL?: ?string, -|}; +}; -export type IntrospectionObjectType = {| +export type IntrospectionObjectType = { +kind: 'OBJECT', +name: string, +description?: ?string, @@ -195,9 +195,9 @@ export type IntrospectionObjectType = {| +interfaces: $ReadOnlyArray< IntrospectionNamedTypeRef, >, -|}; +}; -export type IntrospectionInterfaceType = {| +export type IntrospectionInterfaceType = { +kind: 'INTERFACE', +name: string, +description?: ?string, @@ -208,44 +208,44 @@ export type IntrospectionInterfaceType = {| +possibleTypes: $ReadOnlyArray< IntrospectionNamedTypeRef, >, -|}; +}; -export type IntrospectionUnionType = {| +export type IntrospectionUnionType = { +kind: 'UNION', +name: string, +description?: ?string, +possibleTypes: $ReadOnlyArray< IntrospectionNamedTypeRef, >, -|}; +}; -export type IntrospectionEnumType = {| +export type IntrospectionEnumType = { +kind: 'ENUM', +name: string, +description?: ?string, +enumValues: $ReadOnlyArray, -|}; +}; -export type IntrospectionInputObjectType = {| +export type IntrospectionInputObjectType = { +kind: 'INPUT_OBJECT', +name: string, +description?: ?string, +inputFields: $ReadOnlyArray, -|}; +}; export type IntrospectionListTypeRef< T: IntrospectionTypeRef = IntrospectionTypeRef, -> = {| +> = { +kind: 'LIST', +ofType: T, -|}; +}; export type IntrospectionNonNullTypeRef< T: IntrospectionTypeRef = IntrospectionTypeRef, -> = {| +> = { +kind: 'NON_NULL', +ofType: T, -|}; +}; export type IntrospectionTypeRef = | IntrospectionNamedTypeRef<> @@ -272,40 +272,40 @@ export type IntrospectionInputTypeRef = export type IntrospectionNamedTypeRef< T: IntrospectionType = IntrospectionType, -> = {| +> = { +kind: $PropertyType, +name: string, -|}; +}; -export type IntrospectionField = {| +export type IntrospectionField = { +name: string, +description?: ?string, +args: $ReadOnlyArray, +type: IntrospectionOutputTypeRef, +isDeprecated: boolean, +deprecationReason: ?string, -|}; +}; -export type IntrospectionInputValue = {| +export type IntrospectionInputValue = { +name: string, +description?: ?string, +type: IntrospectionInputTypeRef, +defaultValue: ?string, +isDeprecated?: boolean, +deprecationReason?: ?string, -|}; +}; -export type IntrospectionEnumValue = {| +export type IntrospectionEnumValue = { +name: string, +description?: ?string, +isDeprecated: boolean, +deprecationReason: ?string, -|}; +}; -export type IntrospectionDirective = {| +export type IntrospectionDirective = { +name: string, +description?: ?string, +isRepeatable?: boolean, +locations: $ReadOnlyArray, +args: $ReadOnlyArray, -|}; +}; diff --git a/src/validation/ValidationContext.js b/src/validation/ValidationContext.js index 6db25ecc5b..ece2c0a62f 100644 --- a/src/validation/ValidationContext.js +++ b/src/validation/ValidationContext.js @@ -29,11 +29,11 @@ import type { import { TypeInfo, visitWithTypeInfo } from '../utilities/TypeInfo'; type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode; -type VariableUsage = {| +type VariableUsage = { +node: VariableNode, +type: ?GraphQLInputType, +defaultValue: ?mixed, -|}; +}; /** * An instance of this class is passed as the "this" context to all validators, diff --git a/src/validation/__tests__/validation-test.js b/src/validation/__tests__/validation-test.js index 2abdf6b248..d2eb64bbb1 100644 --- a/src/validation/__tests__/validation-test.js +++ b/src/validation/__tests__/validation-test.js @@ -128,7 +128,7 @@ describe('Validate: Limit maximum number of validation errors', () => { `; const doc = parse(query, { noLocation: true }); - function validateDocument(options: {| maxErrors?: number |}) { + function validateDocument(options: { maxErrors?: number }) { return validate(testSchema, doc, undefined, options); } diff --git a/src/validation/validate.js b/src/validation/validate.js index 8ba03bbfb4..7a4bcf43b6 100644 --- a/src/validation/validate.js +++ b/src/validation/validate.js @@ -34,7 +34,7 @@ export function validate( schema: GraphQLSchema, documentAST: DocumentNode, rules: $ReadOnlyArray = specifiedRules, - options: {| maxErrors?: number |} = { maxErrors: undefined }, + options: { maxErrors?: number } = { maxErrors: undefined }, // @deprecate will be removed in 17.0.0 typeInfo: TypeInfo = new TypeInfo(schema),