Skip to content

Commit 78c4b56

Browse files
committed
fix(Flowtype): Resolve Flow warnings
1 parent 85996c2 commit 78c4b56

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

.flowconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
[ignore]
2-
.*/__tests__/.*
3-
.*/__mocks__/.*
42
.*/coverage/.*
53
.*/resources/.*
64
<PROJECT_ROOT>/lib/.*
@@ -36,7 +34,6 @@
3634
.*/node_modules/uglify.*
3735
.*/node_modules/yargs.*
3836

39-
4037
[include]
4138

4239
[libs]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"homepage": "https://github.com/nodkz/graphql-compose-relay",
2424
"peerDependencies": {
25-
"graphql-compose": ">=1.19.3"
25+
"graphql-compose": ">=1.20.3"
2626
},
2727
"devDependencies": {
2828
"babel-cli": "^6.24.1",

src/__tests__/composeWithRelay-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('composeWithRelay', () => {
2020
});
2121

2222
it('should throw error if got a not TypeComposer', () => {
23+
// $FlowFixMe
2324
expect(() => composeWithRelay(123)).toThrowError('should provide TypeComposer instance');
2425
});
2526

@@ -41,19 +42,23 @@ describe('composeWithRelay', () => {
4142
describe('when pass RootQuery type composer', () => {
4243
it('should add `node` field to RootQuery', () => {
4344
const nodeField = rootQueryComposer.getField('node');
45+
// $FlowFixMe
4446
expect(nodeField.type).toBeInstanceOf(GraphQLInterfaceType);
47+
// $FlowFixMe
4548
expect(nodeField.type.name).toBe('Node');
4649
});
4750
});
4851

4952
describe('when pass User type composer (not RootQuery)', () => {
5053
it('should add or override id field', () => {
5154
const idField = userComposer.getField('id');
55+
// $FlowFixMe
5256
expect(idField.description).toContain('globally unique ID');
5357
});
5458

5559
it('should make id field NonNull', () => {
5660
const idField = userComposer.getField('id');
61+
// $FlowFixMe
5762
expect(idField.type).toBeInstanceOf(GraphQLNonNull);
5863
});
5964

@@ -72,7 +77,9 @@ describe('composeWithRelay', () => {
7277
}
7378
}`;
7479
const result = await graphql.graphql(schema, query);
80+
// $FlowFixMe
7581
expect(result.data.user.id).toBe(toGlobalId('User', 1));
82+
// $FlowFixMe
7683
expect(result.data.user.name).toBe('Pavel');
7784
});
7885

@@ -94,7 +101,9 @@ describe('composeWithRelay', () => {
94101
name
95102
}`;
96103
const result = await graphql.graphql(schema, query);
104+
// $FlowFixMe
97105
expect(result.data.node.id).toBe(toGlobalId('User', 1));
106+
// $FlowFixMe
98107
expect(result.data.node.name).toBe('Pavel');
99108
});
100109

@@ -116,7 +125,9 @@ describe('composeWithRelay', () => {
116125
}
117126
}`;
118127
const result = await graphql.graphql(schema, query);
128+
// $FlowFixMe
119129
expect(result.data.createUser.record.name).toBe('Ok');
130+
// $FlowFixMe
120131
expect(result.data.createUser.clientMutationId).toBe('123');
121132
});
122133
});

src/__tests__/nodeFieldConfig-test.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,36 @@ describe('nodeFieldConfig', () => {
3333
});
3434

3535
it('should return null if args.id not defined', () => {
36-
expect(config.resolve({}, {})).toBeNull();
36+
const source = {};
37+
const args = {};
38+
const context = {};
39+
const info = ({}: any);
40+
expect(config.resolve(source, args, context, info)).toBeNull();
3741
});
3842

3943
it('should return null if findById not defined for type', () => {
40-
expect(config.resolve({}, { id: toGlobalId('UnexistedType', 1) })).toBeNull();
44+
const source = {};
45+
const args = { id: toGlobalId('UnexistedType', 1) };
46+
const context = {};
47+
const info = ({}: any);
48+
expect(config.resolve(source, args, context, info)).toBeNull();
4149
});
4250

4351
it('should return Promise if type exists, but id not exist', () => {
44-
expect(config.resolve({}, { id: toGlobalId('User', 666) })).toBeInstanceOf(Promise);
52+
const source = {};
53+
const args = { id: toGlobalId('User', 666) };
54+
const context = {};
55+
const info = ({}: any);
56+
expect(config.resolve(source, args, context, info)).toBeInstanceOf(Promise);
4557
});
4658

4759
it('should return Promise with user data', async () => {
48-
const res = await config.resolve({}, { id: toGlobalId('User', 1) });
60+
const source = {};
61+
const args = { id: toGlobalId('User', 1) };
62+
const context = {};
63+
const info = ({}: any);
64+
const res = await config.resolve(source, args, context, info);
65+
// $FlowFixMe
4966
expect(res.name).toBe('Pavel');
5067
});
5168
});

src/__tests__/wrapMutationResolver.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('wrapMutationResolver', () => {
3636
);
3737

3838
const type = getNamedType(fieldConfigManyArgsWithoutInput.args.input.type);
39+
// $FlowFixMe
3940
const itc = new InputTypeComposer(type);
4041
expect(itc.hasField('sort')).toBe(true);
4142
expect(itc.hasField('limit')).toBe(true);
@@ -48,6 +49,7 @@ describe('wrapMutationResolver', () => {
4849
);
4950

5051
const type = getNamedType(fieldConfigManyArgsWithInput.args.input.type);
52+
// $FlowFixMe
5153
const itc = new InputTypeComposer(type);
5254
expect(itc.hasField('sort')).toBe(false);
5355
expect(itc.hasField('limit')).toBe(false);

0 commit comments

Comments
 (0)