From 60bb5b9fe1d97586830c53c977ef8bbb41417c75 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Thu, 19 Mar 2020 20:41:20 +0100 Subject: [PATCH] fix(elasticsearch-plugin): Do not expose private facets in search result --- packages/core/e2e/default-search-plugin.e2e-spec.ts | 2 ++ .../elasticsearch-plugin/e2e/elasticsearch-plugin.e2e-spec.ts | 2 ++ packages/elasticsearch-plugin/src/elasticsearch-resolver.ts | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/e2e/default-search-plugin.e2e-spec.ts b/packages/core/e2e/default-search-plugin.e2e-spec.ts index ac806794f0..0f8d97f909 100644 --- a/packages/core/e2e/default-search-plugin.e2e-spec.ts +++ b/packages/core/e2e/default-search-plugin.e2e-spec.ts @@ -282,6 +282,8 @@ describe('Default search plugin', () => { }, }); + await awaitRunningJobs(adminClient); + const result = await shopClient.query( SEARCH_GET_FACET_VALUES, { diff --git a/packages/elasticsearch-plugin/e2e/elasticsearch-plugin.e2e-spec.ts b/packages/elasticsearch-plugin/e2e/elasticsearch-plugin.e2e-spec.ts index 3d5bfc9334..6739579fa2 100644 --- a/packages/elasticsearch-plugin/e2e/elasticsearch-plugin.e2e-spec.ts +++ b/packages/elasticsearch-plugin/e2e/elasticsearch-plugin.e2e-spec.ts @@ -301,6 +301,8 @@ describe('Elasticsearch plugin', () => { }, }); + await awaitRunningJobs(adminClient); + const result = await shopClient.query( SEARCH_GET_FACET_VALUES, { diff --git a/packages/elasticsearch-plugin/src/elasticsearch-resolver.ts b/packages/elasticsearch-plugin/src/elasticsearch-resolver.ts index 37cd614425..8282080f95 100644 --- a/packages/elasticsearch-plugin/src/elasticsearch-resolver.ts +++ b/packages/elasticsearch-plugin/src/elasticsearch-resolver.ts @@ -33,7 +33,8 @@ export class ShopElasticSearchResolver implements Omit> { - return this.elasticsearchService.facetValues(ctx, parent.input, true); + const facetValues = await this.elasticsearchService.facetValues(ctx, parent.input, true); + return facetValues.filter(i => !i.facetValue.facet.isPrivate); } @ResolveProperty()