From 09cee7364d3523c01283e69ce6c1dbd9e7bec997 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 2 Apr 2020 16:53:39 +0300 Subject: [PATCH] Update Flow (#2500) --- .flowconfig | 2 +- package.json | 2 +- src/execution/__tests__/abstract-test.js | 2 +- src/subscription/__tests__/subscribe-test.js | 14 +++++++------- src/subscription/mapAsyncIterator.js | 6 ++---- src/type/__tests__/definition-test.js | 14 +++++++------- .../__tests__/getOperationRootType-test.js | 4 ++-- yarn.lock | 8 ++++---- 8 files changed, 25 insertions(+), 27 deletions(-) diff --git a/.flowconfig b/.flowconfig index 5791eac34a..76267e7deb 100644 --- a/.flowconfig +++ b/.flowconfig @@ -40,4 +40,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)?)\\) suppress_comment=\\(.\\|\n\\)*\\$DisableFlowOnNegativeTest [version] -^0.120.0 +^0.121.0 diff --git a/package.json b/package.json index fbe1e6b748..92f102148f 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "eslint-plugin-flowtype": "4.6.0", "eslint-plugin-graphql-internal": "link:./resources/eslint-rules", "eslint-plugin-import": "2.20.1", - "flow-bin": "0.120.1", + "flow-bin": "0.121.0", "mocha": "7.1.0", "nyc": "15.0.0", "prettier": "2.0.2", diff --git a/src/execution/__tests__/abstract-test.js b/src/execution/__tests__/abstract-test.js index 6d60cc253a..10b07c6d6b 100644 --- a/src/execution/__tests__/abstract-test.js +++ b/src/execution/__tests__/abstract-test.js @@ -403,8 +403,8 @@ describe('Execute: Handles execution of abstract types', () => { const fooInterface = new GraphQLInterfaceType({ name: 'FooInterface', fields: { bar: { type: GraphQLString } }, + // $DisableFlowOnNegativeTest resolveType() { - // $DisableFlowOnNegativeTest return []; }, }); diff --git a/src/subscription/__tests__/subscribe-test.js b/src/subscription/__tests__/subscribe-test.js index 4a0620168d..cff3ef6ef9 100644 --- a/src/subscription/__tests__/subscribe-test.js +++ b/src/subscription/__tests__/subscribe-test.js @@ -160,11 +160,11 @@ describe('Subscription Initialization Phase', () => { // Empty } + // $FlowFixMe const ai = await subscribe(emailSchema, document, { importantEmail: emptyAsyncIterator, }); - // $FlowFixMe ai.next(); ai.return(); }); @@ -215,6 +215,7 @@ describe('Subscription Initialization Phase', () => { }), }); + // $FlowFixMe const subscription = await subscribe({ schema, document: parse(` @@ -228,7 +229,6 @@ describe('Subscription Initialization Phase', () => { importantEmail: {}, }); - // $FlowFixMe await subscription.next(); }); @@ -250,6 +250,7 @@ describe('Subscription Initialization Phase', () => { }), }); + // $FlowFixMe const subscription = await subscribe({ schema, document: parse(` @@ -263,7 +264,6 @@ describe('Subscription Initialization Phase', () => { importantEmail: {}, }); - // $FlowFixMe await subscription.next(); }); @@ -297,6 +297,7 @@ describe('Subscription Initialization Phase', () => { subscription: SubscriptionTypeMultiple, }); + // $FlowFixMe const subscription = await subscribe({ schema, document: parse(` @@ -307,7 +308,6 @@ describe('Subscription Initialization Phase', () => { `), }); - // $FlowFixMe subscription.next(); // Ask for a result, but ignore it. expect(didResolveImportantEmail).to.equal(true); @@ -935,6 +935,7 @@ describe('Subscription Publish Phase', () => { }, ); + // $FlowFixMe const subscription = await subscribe({ schema: erroringEmailSchema, document: parse(` @@ -948,7 +949,6 @@ describe('Subscription Publish Phase', () => { `), }); - // $FlowFixMe const payload1 = await subscription.next(); expect(payload1).to.deep.equal({ done: false, @@ -1007,6 +1007,7 @@ describe('Subscription Publish Phase', () => { (email) => email, ); + // $FlowFixMe const subscription = await subscribe({ schema: erroringEmailSchema, document: parse(` @@ -1020,7 +1021,6 @@ describe('Subscription Publish Phase', () => { `), }); - // $FlowFixMe const payload1 = await subscription.next(); expect(payload1).to.deep.equal({ done: false, @@ -1061,6 +1061,7 @@ describe('Subscription Publish Phase', () => { (email) => email, ); + // $FlowFixMe const subscription = await subscribe({ schema: erroringEmailSchema, document: parse(` @@ -1074,7 +1075,6 @@ describe('Subscription Publish Phase', () => { `), }); - // $FlowFixMe const payload1 = await subscription.next(); expect(payload1).to.deep.equal({ done: false, diff --git a/src/subscription/mapAsyncIterator.js b/src/subscription/mapAsyncIterator.js index 2731dbc6c9..afe05c8d51 100644 --- a/src/subscription/mapAsyncIterator.js +++ b/src/subscription/mapAsyncIterator.js @@ -15,10 +15,9 @@ export default function mapAsyncIterator( ): AsyncGenerator { // $FlowFixMe const iteratorMethod = iterable[SYMBOL_ASYNC_ITERATOR]; - const iterator: AsyncIterator = iteratorMethod.call(iterable); - let $return; + const iterator: any = iteratorMethod.call(iterable); + let $return: any; let abruptClose; - // $FlowFixMe(>=0.68.0) if (typeof iterator.return === 'function') { $return = iterator.return; abruptClose = (error) => { @@ -53,7 +52,6 @@ export default function mapAsyncIterator( : Promise.resolve({ value: undefined, done: true }); }, throw(error) { - // $FlowFixMe(>=0.68.0) if (typeof iterator.throw === 'function') { return iterator.throw(error).then(mapResult, mapReject); } diff --git a/src/type/__tests__/definition-test.js b/src/type/__tests__/definition-test.js index 8003d86883..25803830a2 100644 --- a/src/type/__tests__/definition-test.js +++ b/src/type/__tests__/definition-test.js @@ -336,8 +336,8 @@ describe('Type System: Objects', () => { it('rejects an Object type with a field function that returns incorrect type', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', + // $DisableFlowOnNegativeTest fields() { - // $DisableFlowOnNegativeTest return [{ field: ScalarType }]; }, }); @@ -365,8 +365,8 @@ describe('Type System: Objects', () => { it('rejects an Object type with an isDeprecated instead of deprecationReason on field', () => { const OldObject = new GraphQLObjectType({ name: 'OldObject', + // $DisableFlowOnNegativeTest fields: { - // $DisableFlowOnNegativeTest field: { type: ScalarType, isDeprecated: true }, }, }); @@ -405,8 +405,8 @@ describe('Type System: Objects', () => { it('rejects an empty Object field resolver', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', + // $DisableFlowOnNegativeTest fields: { - // $DisableFlowOnNegativeTest field: { type: ScalarType, resolve: {} }, }, }); @@ -419,8 +419,8 @@ describe('Type System: Objects', () => { it('rejects a constant scalar value resolver', () => { const objType = new GraphQLObjectType({ name: 'SomeObject', + // $DisableFlowOnNegativeTest fields: { - // $DisableFlowOnNegativeTest field: { type: ScalarType, resolve: 0 }, }, }); @@ -724,8 +724,8 @@ describe('Type System: Enums', () => { () => new GraphQLEnumType({ name: 'SomeEnum', + // $DisableFlowOnNegativeTest values: { - // $DisableFlowOnNegativeTest FOO: { isDeprecated: true }, }, }), @@ -809,8 +809,8 @@ describe('Type System: Input Objects', () => { it('rejects an Input Object type with resolvers', () => { const inputObjType = new GraphQLInputObjectType({ name: 'SomeInputObject', + // $DisableFlowOnNegativeTest fields: { - // $DisableFlowOnNegativeTest f: { type: ScalarType, resolve: dummyFunc }, }, }); @@ -822,8 +822,8 @@ describe('Type System: Input Objects', () => { it('rejects an Input Object type with resolver constant', () => { const inputObjType = new GraphQLInputObjectType({ name: 'SomeInputObject', + // $DisableFlowOnNegativeTest fields: { - // $DisableFlowOnNegativeTest f: { type: ScalarType, resolve: {} }, }, }); diff --git a/src/utilities/__tests__/getOperationRootType-test.js b/src/utilities/__tests__/getOperationRootType-test.js index 862f35be67..5f811e9102 100644 --- a/src/utilities/__tests__/getOperationRootType-test.js +++ b/src/utilities/__tests__/getOperationRootType-test.js @@ -149,13 +149,13 @@ describe('getOperationRootType', () => { it('Throws when operation not a valid operation kind', () => { const testSchema = new GraphQLSchema({}); - const doc = parse('{ field }'); const operationNode = { ...getOperationNode(doc), - // $DisableFlowOnNegativeTest operation: 'non_existent_operation', }; + + // $DisableFlowOnNegativeTest expect(() => getOperationRootType(testSchema, operationNode)).to.throw( 'Can only have query, mutation and subscription operations.', ); diff --git a/yarn.lock b/yarn.lock index 67300ce65e..0700943541 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1975,10 +1975,10 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08" integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg== -flow-bin@0.120.1: - version "0.120.1" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.120.1.tgz#ab051d6df71829b70a26a2c90bb81f9d43797cae" - integrity sha512-KgE+d+rKzdXzhweYVJty1QIOOZTTbtnXZf+4SLnmArLvmdfeLreQOZpeLbtq5h79m7HhDzX/HkUkoyu/fmSC2A== +flow-bin@0.121.0: + version "0.121.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.121.0.tgz#e206bdc3d510277f9a847920540f72c49e87c130" + integrity sha512-QYRMs+AoMLj/OTaSo9+8c3kzM/u8YgvfrInp0qzhtzC02Sc2jb3BV/QZWZGjPo+XK3twyyqXrcI3s8MuL1UQRg== foreground-child@^2.0.0: version "2.0.0"