Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/graphql/elasticsearch/catalog/processor.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
11 changes: 8 additions & 3 deletions src/graphql/elasticsearch/catalog/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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 = {}
Expand Down