Skip to content

Commit cb4ac74

Browse files
committed
fix(Flowtype): more strict type checks
1 parent 65baa7f commit cb4ac74

File tree

6 files changed

+14
-24
lines changed

6 files changed

+14
-24
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"globals": {
3737
"Class": true,
3838
"$Shape": true,
39+
"$FlowFixMe": true,
3940
},
4041
"plugins": [
4142
"flowtype",

src/__tests__/composeWithRelay-test.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ describe('composeWithRelay', () => {
2424
});
2525

2626
it('should throw error if got a not TypeComposer', () => {
27-
// $FlowFixMe
28-
expect(() => composeWithRelay(123)).toThrowError('should provide TypeComposer instance');
27+
expect(() => composeWithRelay((123: any))).toThrowError(
28+
'should provide TypeComposer instance'
29+
);
2930
});
3031

3132
it('should throw error if TypeComposer without recordIdFn', () => {
@@ -45,9 +46,8 @@ describe('composeWithRelay', () => {
4546

4647
describe('when pass RootQuery type composer', () => {
4748
it('should add `node` field to RootQuery', () => {
48-
const nodeField = rootQueryComposer.getField('node');
49+
const nodeField: any = rootQueryComposer.getField('node');
4950
expect(nodeField.type).toBeInstanceOf(GraphQLInterfaceType);
50-
// $FlowFixMe
5151
expect(nodeField.type.name).toBe('Node');
5252
});
5353
});
@@ -77,10 +77,8 @@ describe('composeWithRelay', () => {
7777
name
7878
}
7979
}`;
80-
const result = await graphql(schema, query);
81-
// $FlowFixMe
80+
const result: any = await graphql(schema, query);
8281
expect(result.data.user.id).toBe(toGlobalId('User', 1));
83-
// $FlowFixMe
8482
expect(result.data.user.name).toBe('Pavel');
8583
});
8684

@@ -101,10 +99,8 @@ describe('composeWithRelay', () => {
10199
id
102100
name
103101
}`;
104-
const result = await graphql(schema, query);
105-
// $FlowFixMe
102+
const result: any = await graphql(schema, query);
106103
expect(result.data.node.id).toBe(toGlobalId('User', 1));
107-
// $FlowFixMe
108104
expect(result.data.node.name).toBe('Pavel');
109105
});
110106

@@ -125,10 +121,8 @@ describe('composeWithRelay', () => {
125121
clientMutationId
126122
}
127123
}`;
128-
const result = await graphql(schema, query);
129-
// $FlowFixMe
124+
const result: any = await graphql(schema, query);
130125
expect(result.data.createUser.record.name).toBe('Ok');
131-
// $FlowFixMe
132126
expect(result.data.createUser.clientMutationId).toBe('123');
133127
});
134128
});

src/__tests__/nodeFieldConfig-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ describe('nodeFieldConfig', () => {
5959
const args = { id: toGlobalId('User', 1) };
6060
const context = {};
6161
const info = ({}: any);
62-
const res = await config.resolve(source, args, context, info);
63-
// $FlowFixMe
62+
const res: any = await config.resolve(source, args, context, info);
6463
expect(res.name).toBe('Pavel');
6564
});
6665
});

src/__tests__/wrapMutationResolver.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ describe('wrapMutationResolver', () => {
3939
expect.arrayContaining(['input'])
4040
);
4141

42-
const type = getNamedType(fieldConfigManyArgsWithoutInput.args.input.type);
43-
// $FlowFixMe
42+
const type: any = getNamedType(fieldConfigManyArgsWithoutInput.args.input.type);
4443
const itc = new InputTypeComposer(type);
4544
expect(itc.hasField('sort')).toBe(true);
4645
expect(itc.hasField('limit')).toBe(true);
@@ -52,8 +51,7 @@ describe('wrapMutationResolver', () => {
5251
expect.arrayContaining(['input', 'sort', 'limit'])
5352
);
5453

55-
const type = getNamedType(fieldConfigManyArgsWithInput.args.input.type);
56-
// $FlowFixMe
54+
const type: any = getNamedType(fieldConfigManyArgsWithInput.args.input.type);
5755
const itc = new InputTypeComposer(type);
5856
expect(itc.hasField('sort')).toBe(false);
5957
expect(itc.hasField('limit')).toBe(false);

src/nodeFieldConfig.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function getNodeFieldConfig(typeMapForRelayNode: TypeMapForRelayNode) {
1717
type: NodeInterface,
1818
args: {
1919
id: {
20-
type: new GraphQLNonNull(GraphQLID),
20+
type: (new GraphQLNonNull(GraphQLID): $FlowFixMe),
2121
description: 'The globally unique ID among all types',
2222
},
2323
},
@@ -36,7 +36,6 @@ export function getNodeFieldConfig(typeMapForRelayNode: TypeMapForRelayNode) {
3636
return null;
3737
}
3838
const { tc, resolver: findById } = typeMapForRelayNode[type];
39-
4039
if (findById && findById.resolve && tc) {
4140
const graphqlType = tc.getType();
4241

src/wrapMutationResolver.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function wrapMutationResolver<TSource, TContext>(
2626
): Resolver<TSource, TContext> {
2727
const { resolverName, rootTypeName } = opts;
2828

29-
function prepareArgs(newResolver) {
29+
function prepareArgs(newResolver: Resolver<TSource, TContext>) {
3030
let ITC: InputTypeComposer;
3131
if (newResolver.args.input && newResolver.args.input.type) {
3232
const inputNamedType = getNamedType(newResolver.args.input.type);
@@ -36,10 +36,9 @@ export default function wrapMutationResolver<TSource, TContext>(
3636
} else {
3737
// create input arg, and put into all current args
3838

39-
// $FlowFixMe
4039
ITC = InputTypeComposer.create({
4140
name: `Relay${upperFirst(resolverName)}${rootTypeName}Input`,
42-
fields: newResolver.args,
41+
fields: (newResolver.args: any),
4342
});
4443
newResolver.setArgs({
4544
input: {

0 commit comments

Comments
 (0)