diff --git a/src/graphql/elasticsearch/catalog/processor.js b/src/graphql/elasticsearch/catalog/processor.js index 7f4ba72f..28266e90 100755 --- a/src/graphql/elasticsearch/catalog/processor.js +++ b/src/graphql/elasticsearch/catalog/processor.js @@ -1,13 +1,13 @@ import config from 'config' import ProcessorFactory from '../../../processor/factory' -export default function esResultsProcessor (response, entityType, indexName, req, res) { +export default function esResultsProcessor (response, esRequest, entityType, indexName) { return new Promise((resolve, reject) => { const factory = new ProcessorFactory(config) - let resultProcessor = factory.getAdapter(entityType, indexName, req, res) + let resultProcessor = factory.getAdapter(entityType, indexName, esRequest, response) if (!resultProcessor) { - resultProcessor = factory.getAdapter('default', indexName, req, res) // get the default processor + resultProcessor = factory.getAdapter('default', indexName, esRequest, response) // get the default processor } resultProcessor.process(response.hits.hits) diff --git a/src/graphql/elasticsearch/catalog/resolver.js b/src/graphql/elasticsearch/catalog/resolver.js index 50f5e230..d70c75d6 100644 --- a/src/graphql/elasticsearch/catalog/resolver.js +++ b/src/graphql/elasticsearch/catalog/resolver.js @@ -12,7 +12,12 @@ const resolver = { }; async function list (filter, sort, currentPage, pageSize, search, context, rootValue, _sourceInclude, _sourceExclude) { - const { req, res } = context; + let _req = { + query: { + _source_exclude: _sourceExclude, + _source_include: _sourceInclude + } + } let query = buildQuery({ filter: filter, @@ -23,7 +28,7 @@ async function list (filter, sort, currentPage, pageSize, search, context, rootV type: 'product' }); - let esIndex = getIndexName(req.url) + let esIndex = getIndexName(context.req.url) let esResponse = await client.search({ index: esIndex, @@ -35,7 +40,7 @@ async function list (filter, sort, currentPage, pageSize, search, context, rootV if (esResponse && esResponse.hits && esResponse.hits.hits) { // process response result (caluclate taxes etc...) - esResponse.hits.hits = await esResultsProcessor(esResponse, config.elasticsearch.indexTypes[0], esIndex, req, res); + esResponse.hits.hits = await esResultsProcessor(esResponse, _req, config.elasticsearch.indexTypes[0], esIndex); } let response = {}