From c9b2507661398c8c8b42c4d56924792fd8ce2beb Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Tue, 16 Jun 2020 22:06:27 +0300 Subject: [PATCH] Update Flow (#2658) --- .flowconfig | 4 +- package-lock.json | 6 +- package.json | 2 +- src/error/__tests__/formatError-test.js | 6 +- src/execution/__tests__/abstract-test.js | 2 +- src/execution/__tests__/executor-test.js | 6 +- src/language/__tests__/parser-test.js | 4 +- src/language/__tests__/printer-test.js | 3 +- src/language/__tests__/schema-printer-test.js | 3 +- src/subscription/__tests__/subscribe-test.js | 14 ++-- src/type/__tests__/definition-test.js | 84 +++++++++---------- src/type/__tests__/directive-test.js | 8 +- src/type/__tests__/enumType-test.js | 2 +- src/type/__tests__/schema-test.js | 8 +- src/type/__tests__/validation-test.js | 32 +++---- .../__tests__/assertValidName-test.js | 2 +- .../__tests__/buildASTSchema-test.js | 4 +- .../__tests__/buildClientSchema-test.js | 38 ++++----- src/utilities/__tests__/extendSchema-test.js | 4 +- .../__tests__/getOperationRootType-test.js | 2 +- .../__tests__/stripIgnoredCharacters-test.js | 4 +- src/validation/__tests__/validation-test.js | 2 +- 22 files changed, 120 insertions(+), 120 deletions(-) diff --git a/.flowconfig b/.flowconfig index 9b6cc9e48d..09a75ddb7a 100644 --- a/.flowconfig +++ b/.flowconfig @@ -35,8 +35,6 @@ include_warnings=true module.use_strict=true babel_loose_array_spread=true esproposal.optional_chaining=enable -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$DisableFlowOnNegativeTest [version] -^0.126.0 +^0.127.0 diff --git a/package-lock.json b/package-lock.json index 0d34c5d28f..62f6d2e80c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4007,9 +4007,9 @@ "dev": true }, "flow-bin": { - "version": "0.126.1", - "resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.126.1.tgz", - "integrity": "sha512-RI05x7rVzruRVJQN3M4vLEjZMwUHJKhGz9FmL8HN7WiSo66/131EyJS6Vo8PkKyM2pgT9GRWfGP/tXlqS54XUg==", + "version": "0.127.0", + "resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.127.0.tgz", + "integrity": "sha512-ywvCCdV4NJWzrqjFrMU5tAiVGyBiXjsJQ1+/kj8thXyX15V17x8BFvNwoAH97NrUU8T1HzmFBjLzWc0l2319qg==", "dev": true }, "foreground-child": { diff --git a/package.json b/package.json index bd03ae75be..1f24d34559 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "eslint-plugin-internal-rules": "file:./resources/eslint-internal-rules", "eslint-plugin-istanbul": "0.1.1", "eslint-plugin-node": "11.1.0", - "flow-bin": "0.126.1", + "flow-bin": "0.127.0", "mocha": "7.2.0", "nyc": "15.1.0", "prettier": "2.0.5", diff --git a/src/error/__tests__/formatError-test.js b/src/error/__tests__/formatError-test.js index f1638804b0..8659ae2bfa 100644 --- a/src/error/__tests__/formatError-test.js +++ b/src/error/__tests__/formatError-test.js @@ -8,7 +8,7 @@ import { GraphQLError } from '../GraphQLError'; describe('formatError: default error formatter', () => { it('uses default message', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const e = new GraphQLError(); expect(formatError(e)).to.deep.equal({ @@ -47,12 +47,12 @@ describe('formatError: default error formatter', () => { }); it('rejects null and undefined errors', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => formatError(undefined)).to.throw( 'Received null or undefined error.', ); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => formatError(null)).to.throw( 'Received null or undefined error.', ); diff --git a/src/execution/__tests__/abstract-test.js b/src/execution/__tests__/abstract-test.js index 2eae2f679f..38d177c914 100644 --- a/src/execution/__tests__/abstract-test.js +++ b/src/execution/__tests__/abstract-test.js @@ -405,7 +405,7 @@ describe('Execute: Handles execution of abstract types', () => { const fooInterface = new GraphQLInterfaceType({ name: 'FooInterface', fields: { bar: { type: GraphQLString } }, - // $DisableFlowOnNegativeTest + // $FlowExpectedError resolveType() { return []; }, diff --git a/src/execution/__tests__/executor-test.js b/src/execution/__tests__/executor-test.js index affaea0c1e..c6684372e7 100644 --- a/src/execution/__tests__/executor-test.js +++ b/src/execution/__tests__/executor-test.js @@ -32,14 +32,14 @@ describe('Execute: Handles basic execution tasks', () => { }), }); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => execute({ schema })).to.throw('Must provide document.'); }); it('throws if no schema is provided', () => { const document = parse('{ field }'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => execute({ document })).to.throw( 'Expected undefined to be a GraphQL schema.', ); @@ -64,7 +64,7 @@ describe('Execute: Handles basic execution tasks', () => { `); const variableValues = '{ "a": 1 }'; - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => execute({ schema, document, variableValues })).to.throw( 'Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.', ); diff --git a/src/language/__tests__/parser-test.js b/src/language/__tests__/parser-test.js index cf199e479c..0f322a9661 100644 --- a/src/language/__tests__/parser-test.js +++ b/src/language/__tests__/parser-test.js @@ -24,12 +24,12 @@ function expectSyntaxError(text) { describe('Parser', () => { it('asserts that a source to parse was provided', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => parse()).to.throw('Must provide Source. Received: undefined.'); }); it('asserts that an invalid source to parse was provided', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => parse({})).to.throw('Must provide Source. Received: {}.'); }); diff --git a/src/language/__tests__/printer-test.js b/src/language/__tests__/printer-test.js index d64a5bfa3a..a337df9c25 100644 --- a/src/language/__tests__/printer-test.js +++ b/src/language/__tests__/printer-test.js @@ -25,7 +25,8 @@ describe('Printer: Query document', () => { it('produces helpful error messages', () => { const badAST = { random: 'Data' }; - // $DisableFlowOnNegativeTest + + // $FlowExpectedError expect(() => print(badAST)).to.throw( 'Invalid AST Node: { random: "Data" }.', ); diff --git a/src/language/__tests__/schema-printer-test.js b/src/language/__tests__/schema-printer-test.js index 79695a5d77..a60ac83970 100644 --- a/src/language/__tests__/schema-printer-test.js +++ b/src/language/__tests__/schema-printer-test.js @@ -21,7 +21,8 @@ describe('Printer: SDL document', () => { it('produces helpful error messages', () => { const badAST = { random: 'Data' }; - // $DisableFlowOnNegativeTest + + // $FlowExpectedError expect(() => print(badAST)).to.throw( 'Invalid AST Node: { random: "Data" }.', ); diff --git a/src/subscription/__tests__/subscribe-test.js b/src/subscription/__tests__/subscribe-test.js index 0adec2327a..b56a606ff7 100644 --- a/src/subscription/__tests__/subscribe-test.js +++ b/src/subscription/__tests__/subscribe-test.js @@ -322,13 +322,13 @@ describe('Subscription Initialization Phase', () => { `); await expectPromiseToThrow( - // $DisableFlowOnNegativeTest - () => subscribe(null, document), + // $FlowExpectedError + () => subscribe({ schema: null, document }), 'Expected null to be a GraphQL schema.', ); await expectPromiseToThrow( - // $DisableFlowOnNegativeTest + // $FlowExpectedError () => subscribe({ document }), 'Expected undefined to be a GraphQL schema.', ); @@ -336,13 +336,13 @@ describe('Subscription Initialization Phase', () => { it('throws an error if document is missing', async () => { await expectPromiseToThrow( - // $DisableFlowOnNegativeTest - () => subscribe(emailSchema, null), + // $FlowExpectedError + () => subscribe({ schema: emailSchema, document: null }), 'Must provide document.', ); await expectPromiseToThrow( - // $DisableFlowOnNegativeTest + // $FlowExpectedError () => subscribe({ schema: emailSchema }), 'Must provide document.', ); @@ -372,7 +372,7 @@ describe('Subscription Initialization Phase', () => { it('should pass through unexpected errors thrown in subscribe', async () => { let expectedError; try { - // $DisableFlowOnNegativeTest + // $FlowExpectedError await subscribe({ schema: emailSchema, document: {} }); } catch (error) { expectedError = error; diff --git a/src/type/__tests__/definition-test.js b/src/type/__tests__/definition-test.js index 4b21a189b6..03e5620c4b 100644 --- a/src/type/__tests__/definition-test.js +++ b/src/type/__tests__/definition-test.js @@ -95,7 +95,7 @@ describe('Type System: Scalars', () => { }); it('rejects a Scalar type without name', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLScalarType({})).to.throw('Must provide name.'); }); @@ -104,7 +104,7 @@ describe('Type System: Scalars', () => { () => new GraphQLScalarType({ name: 'SomeScalar', - // $DisableFlowOnNegativeTest + // $FlowExpectedError serialize: {}, }), ).to.throw( @@ -129,9 +129,9 @@ describe('Type System: Scalars', () => { () => new GraphQLScalarType({ name: 'SomeScalar', - // $DisableFlowOnNegativeTest + // $FlowExpectedError parseValue: {}, - // $DisableFlowOnNegativeTest + // $FlowExpectedError parseLiteral: {}, }), ).to.throw( @@ -144,7 +144,7 @@ describe('Type System: Scalars', () => { () => new GraphQLScalarType({ name: 'SomeScalar', - // $DisableFlowOnNegativeTest + // $FlowExpectedError specifiedByUrl: {}, }), ).to.throw( @@ -328,7 +328,7 @@ describe('Type System: Objects', () => { }); it('rejects an Object type without name', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLObjectType({})).to.throw('Must provide name.'); }); @@ -336,7 +336,7 @@ describe('Type System: Objects', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', fields: { - // $DisableFlowOnNegativeTest + // $FlowExpectedError f: undefined, }, }); @@ -348,7 +348,7 @@ describe('Type System: Objects', () => { it('rejects an Object type with incorrectly typed fields', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', - // $DisableFlowOnNegativeTest + // $FlowExpectedError fields: [{ field: ScalarType }], }); expect(() => objType.getFields()).to.throw( @@ -359,7 +359,7 @@ describe('Type System: Objects', () => { it('rejects an Object type with a field function that returns incorrect type', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', - // $DisableFlowOnNegativeTest + // $FlowExpectedError fields() { return [{ field: ScalarType }]; }, @@ -375,7 +375,7 @@ describe('Type System: Objects', () => { fields: { badField: { type: ScalarType, - // $DisableFlowOnNegativeTest + // $FlowExpectedError args: [{ badArg: ScalarType }], }, }, @@ -388,7 +388,7 @@ describe('Type System: Objects', () => { it('rejects an Object type with an isDeprecated instead of deprecationReason on field', () => { const OldObject = new GraphQLObjectType({ name: 'OldObject', - // $DisableFlowOnNegativeTest + // $FlowExpectedError fields: { field: { type: ScalarType, isDeprecated: true }, }, @@ -403,7 +403,7 @@ describe('Type System: Objects', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', fields: {}, - // $DisableFlowOnNegativeTest + // $FlowExpectedError interfaces: {}, }); expect(() => objType.getInterfaces()).to.throw( @@ -415,7 +415,7 @@ describe('Type System: Objects', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', fields: {}, - // $DisableFlowOnNegativeTest + // $FlowExpectedError interfaces() { return {}; }, @@ -428,7 +428,7 @@ describe('Type System: Objects', () => { it('rejects an empty Object field resolver', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', - // $DisableFlowOnNegativeTest + // $FlowExpectedError fields: { field: { type: ScalarType, resolve: {} }, }, @@ -442,7 +442,7 @@ describe('Type System: Objects', () => { it('rejects a constant scalar value resolver', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', - // $DisableFlowOnNegativeTest + // $FlowExpectedError fields: { field: { type: ScalarType, resolve: 0 }, }, @@ -459,7 +459,7 @@ describe('Type System: Objects', () => { new GraphQLObjectType({ name: 'AnotherObject', fields: {}, - // $DisableFlowOnNegativeTest + // $FlowExpectedError isTypeOf: {}, }), ).to.throw( @@ -498,7 +498,7 @@ describe('Type System: Interfaces', () => { }); it('rejects an Interface type without name', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLInterfaceType({})).to.throw('Must provide name.'); }); @@ -506,7 +506,7 @@ describe('Type System: Interfaces', () => { const objType = new GraphQLInterfaceType({ name: 'AnotherInterface', fields: {}, - // $DisableFlowOnNegativeTest + // $FlowExpectedError interfaces: {}, }); expect(() => objType.getInterfaces()).to.throw( @@ -518,7 +518,7 @@ describe('Type System: Interfaces', () => { const objType = new GraphQLInterfaceType({ name: 'AnotherInterface', fields: {}, - // $DisableFlowOnNegativeTest + // $FlowExpectedError interfaces() { return {}; }, @@ -534,7 +534,7 @@ describe('Type System: Interfaces', () => { new GraphQLInterfaceType({ name: 'AnotherInterface', fields: {}, - // $DisableFlowOnNegativeTest + // $FlowExpectedError resolveType: {}, }), ).to.throw( @@ -579,7 +579,7 @@ describe('Type System: Unions', () => { }); it('rejects an Union type without name', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLUnionType({})).to.throw('Must provide name.'); }); @@ -589,7 +589,7 @@ describe('Type System: Unions', () => { new GraphQLUnionType({ name: 'SomeUnion', types: [], - // $DisableFlowOnNegativeTest + // $FlowExpectedError resolveType: {}, }), ).to.throw( @@ -600,7 +600,7 @@ describe('Type System: Unions', () => { it('rejects a Union type with incorrectly typed types', () => { const unionType = new GraphQLUnionType({ name: 'SomeUnion', - // $DisableFlowOnNegativeTest + // $FlowExpectedError types: { ObjectType }, }); @@ -699,7 +699,7 @@ describe('Type System: Enums', () => { }); it('rejects an Enum type without name', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLEnumType({ values: {} })).to.throw( 'Must provide name.', ); @@ -710,7 +710,7 @@ describe('Type System: Enums', () => { () => new GraphQLEnumType({ name: 'SomeEnum', - // $DisableFlowOnNegativeTest + // $FlowExpectedError values: [{ FOO: 10 }], }), ).to.throw('SomeEnum values must be an object with value names as keys.'); @@ -721,7 +721,7 @@ describe('Type System: Enums', () => { () => new GraphQLEnumType({ name: 'SomeEnum', - // $DisableFlowOnNegativeTest + // $FlowExpectedError values: { FOO: null }, }), ).to.throw( @@ -734,7 +734,7 @@ describe('Type System: Enums', () => { () => new GraphQLEnumType({ name: 'SomeEnum', - // $DisableFlowOnNegativeTest + // $FlowExpectedError values: { FOO: 10 }, }), ).to.throw( @@ -747,7 +747,7 @@ describe('Type System: Enums', () => { () => new GraphQLEnumType({ name: 'SomeEnum', - // $DisableFlowOnNegativeTest + // $FlowExpectedError values: { FOO: { isDeprecated: true }, }, @@ -799,7 +799,7 @@ describe('Type System: Input Objects', () => { }); it('rejects an Input Object type without name', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLInputObjectType({})).to.throw( 'Must provide name.', ); @@ -808,7 +808,7 @@ describe('Type System: Input Objects', () => { it('rejects an Input Object type with incorrect fields', () => { const inputObjType = new GraphQLInputObjectType({ name: 'SomeInputObject', - // $DisableFlowOnNegativeTest + // $FlowExpectedError fields: [], }); expect(() => inputObjType.getFields()).to.throw( @@ -819,7 +819,7 @@ describe('Type System: Input Objects', () => { it('rejects an Input Object type with fields function that returns incorrect type', () => { const inputObjType = new GraphQLInputObjectType({ name: 'SomeInputObject', - // $DisableFlowOnNegativeTest + // $FlowExpectedError fields: () => [], }); expect(() => inputObjType.getFields()).to.throw( @@ -832,7 +832,7 @@ describe('Type System: Input Objects', () => { it('rejects an Input Object type with resolvers', () => { const inputObjType = new GraphQLInputObjectType({ name: 'SomeInputObject', - // $DisableFlowOnNegativeTest + // $FlowExpectedError fields: { f: { type: ScalarType, resolve: dummyFunc }, }, @@ -845,7 +845,7 @@ describe('Type System: Input Objects', () => { it('rejects an Input Object type with resolver constant', () => { const inputObjType = new GraphQLInputObjectType({ name: 'SomeInputObject', - // $DisableFlowOnNegativeTest + // $FlowExpectedError fields: { f: { type: ScalarType, resolve: {} }, }, @@ -874,15 +874,15 @@ describe('Type System: List', () => { }); it('rejects a non-type as item type of list', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expectList({}).to.throw('Expected {} to be a GraphQL type.'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expectList(String).to.throw( 'Expected [function String] to be a GraphQL type.', ); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expectList(null).to.throw('Expected null to be a GraphQL type.'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expectList(undefined).to.throw('Expected undefined to be a GraphQL type.'); }); }); @@ -904,21 +904,21 @@ describe('Type System: Non-Null', () => { }); it('rejects a non-type as nullable type of non-null', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expectNonNull(NonNullScalarType).to.throw( 'Expected Scalar! to be a GraphQL nullable type.', ); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expectNonNull({}).to.throw('Expected {} to be a GraphQL nullable type.'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expectNonNull(String).to.throw( 'Expected [function String] to be a GraphQL nullable type.', ); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expectNonNull(null).to.throw( 'Expected null to be a GraphQL nullable type.', ); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expectNonNull(undefined).to.throw( 'Expected undefined to be a GraphQL nullable type.', ); diff --git a/src/type/__tests__/directive-test.js b/src/type/__tests__/directive-test.js index 38bbe852a9..178ca4db91 100644 --- a/src/type/__tests__/directive-test.js +++ b/src/type/__tests__/directive-test.js @@ -85,7 +85,7 @@ describe('Type System: Directive', () => { }); it('rejects an unnamed directive', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLDirective({ locations: ['Query'] })).to.throw( 'Directive must be named.', ); @@ -97,21 +97,21 @@ describe('Type System: Directive', () => { new GraphQLDirective({ name: 'Foo', locations: ['QUERY'], - // $DisableFlowOnNegativeTest + // $FlowExpectedError args: [], }), ).to.throw('@Foo args must be an object with argument names as keys.'); }); it('rejects a directive with undefined locations', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLDirective({ name: 'Foo' })).to.throw( '@Foo locations must be an Array.', ); }); it('rejects a directive with incorrectly typed locations', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLDirective({ name: 'Foo', locations: {} })).to.throw( '@Foo locations must be an Array.', ); diff --git a/src/type/__tests__/enumType-test.js b/src/type/__tests__/enumType-test.js index e4b12195cb..6a7c40329b 100644 --- a/src/type/__tests__/enumType-test.js +++ b/src/type/__tests__/enumType-test.js @@ -365,7 +365,7 @@ describe('Type System: Enum Values', () => { const oneValue = ComplexEnum.getValue('ONE'); expect(oneValue).to.include({ name: 'ONE', value: Complex1 }); - // $DisableFlowOnNegativeTest + // $FlowExpectedError const badUsage = ComplexEnum.getValue(Complex1); expect(badUsage).to.equal(undefined); }); diff --git a/src/type/__tests__/schema-test.js b/src/type/__tests__/schema-test.js index eee7f12029..255e44883a 100644 --- a/src/type/__tests__/schema-test.js +++ b/src/type/__tests__/schema-test.js @@ -331,11 +331,11 @@ describe('Type System: Schema', () => { }); it('checks the configuration for mistakes', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLSchema(JSON.parse)).to.throw(); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLSchema({ types: {} })).to.throw(); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLSchema({ directives: {} })).to.throw(); }); }); @@ -364,7 +364,7 @@ describe('Type System: Schema', () => { }); const types = [{}, query, {}]; - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => new GraphQLSchema({ query, types })).to.throw( 'One of the provided types for building the Schema is missing a name.', ); diff --git a/src/type/__tests__/validation-test.js b/src/type/__tests__/validation-test.js index 599ed20285..b4739b4310 100644 --- a/src/type/__tests__/validation-test.js +++ b/src/type/__tests__/validation-test.js @@ -388,7 +388,7 @@ describe('Type System: A Schema must have Object root types', () => { it('rejects a Schema whose types are incorrectly typed', () => { const schema = new GraphQLSchema({ query: SomeObjectType, - // $DisableFlowOnNegativeTest + // $FlowExpectedError types: [{ name: 'SomeType' }, SomeDirective], }); expect(validateSchema(schema)).to.deep.equal([ @@ -405,7 +405,7 @@ describe('Type System: A Schema must have Object root types', () => { it('rejects a Schema whose directives are incorrectly typed', () => { const schema = new GraphQLSchema({ query: SomeObjectType, - // $DisableFlowOnNegativeTest + // $FlowExpectedError directives: [null, 'SomeDirective', SomeScalarType], }); expect(validateSchema(schema)).to.deep.equal([ @@ -683,7 +683,7 @@ describe('Type System: Union types must be valid', () => { for (const memberType of badUnionMemberTypes) { const badUnion = new GraphQLUnionType({ name: 'BadUnion', - // $DisableFlowOnNegativeTest + // $FlowExpectedError types: [memberType], }); const badSchema = schemaWithFieldType(badUnion); @@ -1005,7 +1005,7 @@ describe('Type System: Object fields must have output types', () => { } it('rejects an empty Object field type', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithObjectFieldOfType(undefined); expect(validateSchema(schema)).to.deep.equal([ { @@ -1018,7 +1018,7 @@ describe('Type System: Object fields must have output types', () => { for (const type of notOutputTypes) { const typeStr = inspect(type); it(`rejects a non-output type as an Object field type: ${typeStr}`, () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithObjectFieldOfType(type); expect(validateSchema(schema)).to.deep.equal([ { @@ -1029,7 +1029,7 @@ describe('Type System: Object fields must have output types', () => { } it('rejects a non-type value as an Object field type', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithObjectFieldOfType(Number); expect(validateSchema(schema)).to.deep.equal([ { @@ -1067,7 +1067,7 @@ describe('Type System: Objects can only implement unique interfaces', () => { const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'BadObject', - // $DisableFlowOnNegativeTest + // $FlowExpectedError interfaces: [undefined], fields: { f: { type: GraphQLString } }, }), @@ -1326,7 +1326,7 @@ describe('Type System: Interface fields must have output types', () => { } it('rejects an empty Interface field type', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithInterfaceFieldOfType(undefined); expect(validateSchema(schema)).to.deep.equal([ { @@ -1343,7 +1343,7 @@ describe('Type System: Interface fields must have output types', () => { for (const type of notOutputTypes) { const typeStr = inspect(type); it(`rejects a non-output type as an Interface field type: ${typeStr}`, () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithInterfaceFieldOfType(type); expect(validateSchema(schema)).to.deep.equal([ { @@ -1357,7 +1357,7 @@ describe('Type System: Interface fields must have output types', () => { } it('rejects a non-type value as an Interface field type', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithInterfaceFieldOfType(Number); expect(validateSchema(schema)).to.deep.equal([ { @@ -1462,7 +1462,7 @@ describe('Type System: Arguments must have input types', () => { } it('rejects an empty field arg type', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithArgOfType(undefined); expect(validateSchema(schema)).to.deep.equal([ { @@ -1479,7 +1479,7 @@ describe('Type System: Arguments must have input types', () => { for (const type of notInputTypes) { const typeStr = inspect(type); it(`rejects a non-input type as a field arg type: ${typeStr}`, () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithArgOfType(type); expect(validateSchema(schema)).to.deep.equal([ { @@ -1493,7 +1493,7 @@ describe('Type System: Arguments must have input types', () => { } it('rejects a non-type value as a field arg type', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithArgOfType(Number); expect(validateSchema(schema)).to.deep.equal([ { @@ -1563,7 +1563,7 @@ describe('Type System: Input Object fields must have input types', () => { } it('rejects an empty input field type', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithInputFieldOfType(undefined); expect(validateSchema(schema)).to.deep.equal([ { @@ -1576,7 +1576,7 @@ describe('Type System: Input Object fields must have input types', () => { for (const type of notInputTypes) { const typeStr = inspect(type); it(`rejects a non-input type as an input field type: ${typeStr}`, () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithInputFieldOfType(type); expect(validateSchema(schema)).to.deep.equal([ { @@ -1587,7 +1587,7 @@ describe('Type System: Input Object fields must have input types', () => { } it('rejects a non-type value as an input field type', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError const schema = schemaWithInputFieldOfType(Number); expect(validateSchema(schema)).to.deep.equal([ { diff --git a/src/utilities/__tests__/assertValidName-test.js b/src/utilities/__tests__/assertValidName-test.js index a05c694bd3..8247c080c6 100644 --- a/src/utilities/__tests__/assertValidName-test.js +++ b/src/utilities/__tests__/assertValidName-test.js @@ -17,7 +17,7 @@ describe('assertValidName()', () => { }); it('throws for non-strings', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => assertValidName({})).to.throw('Expected name to be a string.'); }); diff --git a/src/utilities/__tests__/buildASTSchema-test.js b/src/utilities/__tests__/buildASTSchema-test.js index 25a353a869..1d74e35695 100644 --- a/src/utilities/__tests__/buildASTSchema-test.js +++ b/src/utilities/__tests__/buildASTSchema-test.js @@ -1120,12 +1120,12 @@ describe('Schema Builder', () => { }); it('Rejects invalid AST', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => buildASTSchema(null)).to.throw( 'Must provide valid Document AST', ); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => buildASTSchema({})).to.throw( 'Must provide valid Document AST', ); diff --git a/src/utilities/__tests__/buildClientSchema-test.js b/src/utilities/__tests__/buildClientSchema-test.js index 04fdb0ef7e..425dfd9d19 100644 --- a/src/utilities/__tests__/buildClientSchema-test.js +++ b/src/utilities/__tests__/buildClientSchema-test.js @@ -79,7 +79,7 @@ describe('Type System: build schema from introspection', () => { const schema = buildSchema(sdl); const introspection = introspectionFromSchema(schema); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete introspection.__schema.queryType; const clientSchema = buildClientSchema(introspection); @@ -483,7 +483,7 @@ describe('Type System: build schema from introspection', () => { const schema = buildSchema(sdl); const introspection = introspectionFromSchema(schema); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete introspection.__schema.directives; const clientSchema = buildClientSchema(introspection); @@ -604,12 +604,12 @@ describe('Type System: build schema from introspection', () => { `); it('throws when introspection is missing __schema property', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => buildClientSchema(null)).to.throw( 'Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: null.', ); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => buildClientSchema({})).to.throw( 'Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: {}.', ); @@ -618,7 +618,7 @@ describe('Type System: build schema from introspection', () => { it('throws when referenced unknown type', () => { const introspection = introspectionFromSchema(dummySchema); - // $DisableFlowOnNegativeTest + // $FlowExpectedError introspection.__schema.types = introspection.__schema.types.filter( ({ name }) => name !== 'Query', ); @@ -636,7 +636,7 @@ describe('Type System: build schema from introspection', () => { `); const introspection = introspectionFromSchema(schema); - // $DisableFlowOnNegativeTest + // $FlowExpectedError introspection.__schema.types = introspection.__schema.types.filter( ({ name }) => name !== 'Float', ); @@ -651,7 +651,7 @@ describe('Type System: build schema from introspection', () => { expect(introspection).to.have.nested.property('__schema.queryType.name'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete introspection.__schema.queryType.name; expect(() => buildClientSchema(introspection)).to.throw( @@ -667,7 +667,7 @@ describe('Type System: build schema from introspection', () => { expect(queryTypeIntrospection).to.have.property('kind'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete queryTypeIntrospection.kind; expect(() => buildClientSchema(introspection)).to.throw( @@ -683,7 +683,7 @@ describe('Type System: build schema from introspection', () => { expect(queryTypeIntrospection).to.have.property('interfaces'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete queryTypeIntrospection.interfaces; expect(() => buildClientSchema(introspection)).to.throw( @@ -698,7 +698,7 @@ describe('Type System: build schema from introspection', () => { ); expect(someInterfaceIntrospection).to.have.property('interfaces'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError someInterfaceIntrospection.interfaces = null; const clientSchema = buildClientSchema(introspection); @@ -713,7 +713,7 @@ describe('Type System: build schema from introspection', () => { expect(queryTypeIntrospection).to.have.property('fields'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete queryTypeIntrospection.fields; expect(() => buildClientSchema(introspection)).to.throw( @@ -729,7 +729,7 @@ describe('Type System: build schema from introspection', () => { expect(queryTypeIntrospection).to.have.nested.property('fields[0].args'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete queryTypeIntrospection.fields[0].args; expect(() => buildClientSchema(introspection)).to.throw( @@ -747,7 +747,7 @@ describe('Type System: build schema from introspection', () => { 'fields[0].args[0].type.name', 'String', ); - // $DisableFlowOnNegativeTest + // $FlowExpectedError queryTypeIntrospection.fields[0].args[0].type.name = 'SomeUnion'; expect(() => buildClientSchema(introspection)).to.throw( @@ -765,7 +765,7 @@ describe('Type System: build schema from introspection', () => { 'fields[0].type.name', 'String', ); - // $DisableFlowOnNegativeTest + // $FlowExpectedError queryTypeIntrospection.fields[0].type.name = 'SomeInputObject'; expect(() => buildClientSchema(introspection)).to.throw( @@ -781,7 +781,7 @@ describe('Type System: build schema from introspection', () => { expect(someUnionIntrospection).to.have.property('possibleTypes'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete someUnionIntrospection.possibleTypes; expect(() => buildClientSchema(introspection)).to.throw( @@ -797,7 +797,7 @@ describe('Type System: build schema from introspection', () => { expect(someEnumIntrospection).to.have.property('enumValues'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete someEnumIntrospection.enumValues; expect(() => buildClientSchema(introspection)).to.throw( @@ -813,7 +813,7 @@ describe('Type System: build schema from introspection', () => { expect(someInputObjectIntrospection).to.have.property('inputFields'); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete someInputObjectIntrospection.inputFields; expect(() => buildClientSchema(introspection)).to.throw( @@ -830,7 +830,7 @@ describe('Type System: build schema from introspection', () => { locations: ['QUERY'], }); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete someDirectiveIntrospection.locations; expect(() => buildClientSchema(introspection)).to.throw( @@ -847,7 +847,7 @@ describe('Type System: build schema from introspection', () => { args: [], }); - // $DisableFlowOnNegativeTest + // $FlowExpectedError delete someDirectiveIntrospection.args; expect(() => buildClientSchema(introspection)).to.throw( diff --git a/src/utilities/__tests__/extendSchema-test.js b/src/utilities/__tests__/extendSchema-test.js index 3c2ecb9798..0abea04353 100644 --- a/src/utilities/__tests__/extendSchema-test.js +++ b/src/utilities/__tests__/extendSchema-test.js @@ -1244,12 +1244,12 @@ describe('extendSchema', () => { it('Rejects invalid AST', () => { const schema = new GraphQLSchema({}); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => extendSchema(schema, null)).to.throw( 'Must provide valid Document AST', ); - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => extendSchema(schema, {})).to.throw( 'Must provide valid Document AST', ); diff --git a/src/utilities/__tests__/getOperationRootType-test.js b/src/utilities/__tests__/getOperationRootType-test.js index 5f811e9102..546caf3bc4 100644 --- a/src/utilities/__tests__/getOperationRootType-test.js +++ b/src/utilities/__tests__/getOperationRootType-test.js @@ -155,7 +155,7 @@ describe('getOperationRootType', () => { operation: 'non_existent_operation', }; - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => getOperationRootType(testSchema, operationNode)).to.throw( 'Can only have query, mutation and subscription operations.', ); diff --git a/src/utilities/__tests__/stripIgnoredCharacters-test.js b/src/utilities/__tests__/stripIgnoredCharacters-test.js index 8ac48694f0..65d70cff32 100644 --- a/src/utilities/__tests__/stripIgnoredCharacters-test.js +++ b/src/utilities/__tests__/stripIgnoredCharacters-test.js @@ -101,14 +101,14 @@ function expectStripped(docString) { describe('stripIgnoredCharacters', () => { it('asserts that a source was provided', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => stripIgnoredCharacters()).to.throw( 'Must provide string or Source. Received: undefined.', ); }); it('asserts that a valid source was provided', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => stripIgnoredCharacters({})).to.throw( 'Must provide string or Source. Received: {}.', ); diff --git a/src/validation/__tests__/validation-test.js b/src/validation/__tests__/validation-test.js index 4ddb16d4f1..5461d5be43 100644 --- a/src/validation/__tests__/validation-test.js +++ b/src/validation/__tests__/validation-test.js @@ -16,7 +16,7 @@ import { testSchema } from './harness'; describe('Validate: Supports full validation', () => { it('rejects invalid documents', () => { - // $DisableFlowOnNegativeTest + // $FlowExpectedError expect(() => validate(testSchema, null)).to.throw('Must provide document.'); });