Skip to content

Commit 7aedf3b

Browse files
committed
wip: Search resolver
1 parent 8edee3f commit 7aedf3b

File tree

7 files changed

+520
-446
lines changed

7 files changed

+520
-446
lines changed

src/ElasticApiParser.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,10 @@ export default class ElasticApiParser {
237237
return this.reassembleNestedFields(result);
238238
}
239239

240-
generateFieldConfig(methodName: string): GraphQLFieldConfig<*, *> {
240+
generateFieldConfig(
241+
methodName: string,
242+
methodArgs: { [paramName: string]: mixed }
243+
): GraphQLFieldConfig<*, *> {
241244
if (!methodName) {
242245
throw new Error(`You should provide Elastic search method.`);
243246
}
@@ -260,7 +263,7 @@ export default class ElasticApiParser {
260263
description,
261264
args: argMap,
262265
resolve: (src, args, context) => {
263-
const client = context.elasticClient || this.elasticClient;
266+
const client = (context && context.elasticClient) || this.elasticClient;
264267

265268
if (!client) {
266269
throw new Error(
@@ -270,10 +273,13 @@ export default class ElasticApiParser {
270273
}
271274

272275
if (Array.isArray(elasticMethod)) {
273-
return client[elasticMethod[0]][elasticMethod[1]](args);
276+
return client[elasticMethod[0]][elasticMethod[1]]({
277+
...methodArgs,
278+
...args,
279+
});
274280
}
275281

276-
return client[elasticMethod](args);
282+
return client[elasticMethod]({ ...methodArgs, ...args });
277283
},
278284
};
279285
}

src/__mocks__/cv.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {
2+
inputPropertiesToGraphQLTypes,
3+
convertToSourceTC,
4+
} from '../mappingConverter';
5+
import cvMapping from './cvMapping';
6+
7+
export const CvFieldMap = inputPropertiesToGraphQLTypes(cvMapping);
8+
export const CvTC = convertToSourceTC(cvMapping, 'Cv');

0 commit comments

Comments
 (0)