Skip to content

Commit

Permalink
Update Flow (#2500)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Apr 2, 2020
1 parent a8f73db commit 09cee73
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$DisableFlowOnNegativeTest

[version]
^0.120.0
^0.121.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/abstract-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
},
});
Expand Down
14 changes: 7 additions & 7 deletions src/subscription/__tests__/subscribe-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ describe('Subscription Initialization Phase', () => {
// Empty
}

// $FlowFixMe
const ai = await subscribe(emailSchema, document, {
importantEmail: emptyAsyncIterator,
});

// $FlowFixMe
ai.next();
ai.return();
});
Expand Down Expand Up @@ -215,6 +215,7 @@ describe('Subscription Initialization Phase', () => {
}),
});

// $FlowFixMe
const subscription = await subscribe({
schema,
document: parse(`
Expand All @@ -228,7 +229,6 @@ describe('Subscription Initialization Phase', () => {
importantEmail: {},
});

// $FlowFixMe
await subscription.next();
});

Expand All @@ -250,6 +250,7 @@ describe('Subscription Initialization Phase', () => {
}),
});

// $FlowFixMe
const subscription = await subscribe({
schema,
document: parse(`
Expand All @@ -263,7 +264,6 @@ describe('Subscription Initialization Phase', () => {
importantEmail: {},
});

// $FlowFixMe
await subscription.next();
});

Expand Down Expand Up @@ -297,6 +297,7 @@ describe('Subscription Initialization Phase', () => {
subscription: SubscriptionTypeMultiple,
});

// $FlowFixMe
const subscription = await subscribe({
schema,
document: parse(`
Expand All @@ -307,7 +308,6 @@ describe('Subscription Initialization Phase', () => {
`),
});

// $FlowFixMe
subscription.next(); // Ask for a result, but ignore it.

expect(didResolveImportantEmail).to.equal(true);
Expand Down Expand Up @@ -935,6 +935,7 @@ describe('Subscription Publish Phase', () => {
},
);

// $FlowFixMe
const subscription = await subscribe({
schema: erroringEmailSchema,
document: parse(`
Expand All @@ -948,7 +949,6 @@ describe('Subscription Publish Phase', () => {
`),
});

// $FlowFixMe
const payload1 = await subscription.next();
expect(payload1).to.deep.equal({
done: false,
Expand Down Expand Up @@ -1007,6 +1007,7 @@ describe('Subscription Publish Phase', () => {
(email) => email,
);

// $FlowFixMe
const subscription = await subscribe({
schema: erroringEmailSchema,
document: parse(`
Expand All @@ -1020,7 +1021,6 @@ describe('Subscription Publish Phase', () => {
`),
});

// $FlowFixMe
const payload1 = await subscription.next();
expect(payload1).to.deep.equal({
done: false,
Expand Down Expand Up @@ -1061,6 +1061,7 @@ describe('Subscription Publish Phase', () => {
(email) => email,
);

// $FlowFixMe
const subscription = await subscribe({
schema: erroringEmailSchema,
document: parse(`
Expand All @@ -1074,7 +1075,6 @@ describe('Subscription Publish Phase', () => {
`),
});

// $FlowFixMe
const payload1 = await subscription.next();
expect(payload1).to.deep.equal({
done: false,
Expand Down
6 changes: 2 additions & 4 deletions src/subscription/mapAsyncIterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ export default function mapAsyncIterator<T, U>(
): AsyncGenerator<U, void, void> {
// $FlowFixMe
const iteratorMethod = iterable[SYMBOL_ASYNC_ITERATOR];
const iterator: AsyncIterator<T> = 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) => {
Expand Down Expand Up @@ -53,7 +52,6 @@ export default function mapAsyncIterator<T, U>(
: Promise.resolve({ value: undefined, done: true });
},
throw(error) {
// $FlowFixMe(>=0.68.0)
if (typeof iterator.throw === 'function') {
return iterator.throw(error).then(mapResult, mapReject);
}
Expand Down
14 changes: 7 additions & 7 deletions src/type/__tests__/definition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }];
},
});
Expand Down Expand Up @@ -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 },
},
});
Expand Down Expand Up @@ -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: {} },
},
});
Expand All @@ -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 },
},
});
Expand Down Expand Up @@ -724,8 +724,8 @@ describe('Type System: Enums', () => {
() =>
new GraphQLEnumType({
name: 'SomeEnum',
// $DisableFlowOnNegativeTest
values: {
// $DisableFlowOnNegativeTest
FOO: { isDeprecated: true },
},
}),
Expand Down Expand Up @@ -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 },
},
});
Expand All @@ -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: {} },
},
});
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/__tests__/getOperationRootType-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 09cee73

Please sign in to comment.