Skip to content

Commit 5fb1859

Browse files
committed
fix(Flowtype): Resolve Flowtype warnings
1 parent ecbc64e commit 5fb1859

File tree

20 files changed

+47
-53
lines changed

20 files changed

+47
-53
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"peerDependencies": {
2929
"elasticsearch": ">=12.0.0 || >=13.0.0",
30-
"graphql-compose": ">=1.20.1"
30+
"graphql-compose": ">=1.20.2"
3131
},
3232
"devDependencies": {
3333
"babel-cli": "^6.24.1",
@@ -48,7 +48,7 @@
4848
"express-graphql": "^0.6.6",
4949
"flow-bin": "^0.47.0",
5050
"graphql": "^0.10.1",
51-
"graphql-compose": "^1.20.1",
51+
"graphql-compose": "^1.20.2",
5252
"jest": "^20.0.4",
5353
"jest-babel": "^1.0.1",
5454
"npm-run-all": "^4.0.1",

src/__mocks__/cv.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import {
2-
inputPropertiesToGraphQLTypes,
3-
convertToSourceTC,
4-
} from '../mappingConverter';
1+
/* @flow */
2+
3+
import { inputPropertiesToGraphQLTypes, convertToSourceTC } from '../mappingConverter';
54
import cvMapping from './cvMapping';
65

76
export const CvFieldMap = inputPropertiesToGraphQLTypes(cvMapping);

src/__mocks__/cvMapping.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* @flow */
2+
13
export default {
24
properties: {
35
avatarUrl: {

src/__mocks__/elasticClient.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* @flow */
2+
13
import elasticsearch from 'elasticsearch';
24

35
const elasticClient = new elasticsearch.Client({

src/__tests__/ElasticApiParser-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ describe('ElasticApiParser', () => {
167167
);
168168
const doxAST = dox.parseComments(source, { raw: true });
169169
expect(ElasticApiParser.parseParamsDescription(doxAST[0])).toMatchObject({
170-
analyzeWildcard: 'Specify whether wildcard and prefix queries should be analyzed (default: false)',
170+
analyzeWildcard:
171+
'Specify whether wildcard and prefix queries should be analyzed (default: false)',
171172
analyzer: 'The analyzer to use for the query string',
172173
from: 'Starting offset (default: 0)',
173174
});

src/__tests__/mappingConverter-test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,12 @@ describe('PropertiesConverter', () => {
141141
'ComplexType'
142142
);
143143
expect(type).toBeInstanceOf(GraphQLObjectType);
144-
const tc = TypeComposer.create(type);
145-
expect(tc.getTypeName()).toEqual('ComplexType');
146-
expect(tc.getFieldNames()).toEqual(expect.arrayContaining(['big', 'thumb']));
147-
expect(tc.getFieldType('big')).toEqual(GraphQLString);
144+
if (type instanceof GraphQLObjectType) {
145+
const tc = TypeComposer.create(type);
146+
expect(tc.getTypeName()).toEqual('ComplexType');
147+
expect(tc.getFieldNames()).toEqual(expect.arrayContaining(['big', 'thumb']));
148+
expect(tc.getFieldType('big')).toEqual(GraphQLString);
149+
}
148150
});
149151
});
150152

src/elasticDSL/Aggs/Aggs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* @flow */
2+
13
import { getAggBlockITC } from './AggBlock';
24

35
export function getAggsITC(opts: mixed) {
@@ -10,7 +12,7 @@ export type ElasticAggsT = {
1012

1113
export type ElasticAggsRulesT = {
1214
[aggOperationName: string]: mixed,
13-
aggs: ElasticAggsT,
15+
aggs?: ElasticAggsT,
1416
};
1517

1618
export type GqlAggBlock = {
@@ -20,7 +22,7 @@ export type GqlAggBlock = {
2022

2123
export type GqlAggRules = {
2224
[aggOperationName: string]: mixed,
23-
aggs: GqlAggBlock[],
25+
aggs?: GqlAggBlock[],
2426
};
2527

2628
export function prepareAggsInResolve(

src/elasticDSL/Query/Compound/Bool.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ function prepareQueryMayBeArray(vals, fieldMap) {
8686
return prepareQueryInResolve(vals, fieldMap);
8787
}
8888

89-
export function prepareBoolInResolve(
90-
bool: any,
91-
fieldMap: mixed
92-
): { [argName: string]: any } {
89+
export function prepareBoolInResolve(bool: any, fieldMap: mixed): { [argName: string]: any } {
9390
/* eslint-disable no-param-reassign */
9491
if (bool.must) {
9592
bool.must = prepareQueryMayBeArray(bool.must, fieldMap);

src/elasticDSL/Query/Compound/ConstantScore.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ export function prepareConstantScoreInResolve(
3232
fieldMap: mixed
3333
): { [argName: string]: any } {
3434
if (constant_score.filter) {
35-
constant_score.filter = prepareQueryInResolve(
36-
constant_score.filter,
37-
fieldMap
38-
);
35+
constant_score.filter = prepareQueryInResolve(constant_score.filter, fieldMap);
3936
}
4037

4138
return constant_score;

src/elasticDSL/Query/Compound/DisMax.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,9 @@ export function getDisMaxITC(opts: mixed = {}): InputTypeComposer {
3030
}
3131

3232
/* eslint-disable no-param-reassign, camelcase */
33-
export function prepareDisMaxResolve(
34-
dis_max: any,
35-
fieldMap: mixed
36-
): { [argName: string]: any } {
33+
export function prepareDisMaxResolve(dis_max: any, fieldMap: mixed): { [argName: string]: any } {
3734
if (Array.isArray(dis_max.queries)) {
38-
dis_max.queries = dis_max.queries.map(query =>
39-
prepareQueryInResolve(query, fieldMap)
40-
);
35+
dis_max.queries = dis_max.queries.map(query => prepareQueryInResolve(query, fieldMap));
4136
}
4237

4338
return dis_max;

0 commit comments

Comments
 (0)