Skip to content

Commit

Permalink
fix(elasticsearch-plugin): Do not expose private facets in search result
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Mar 19, 2020
1 parent 8b79617 commit 60bb5b9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/core/e2e/default-search-plugin.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ describe('Default search plugin', () => {
},
});

await awaitRunningJobs(adminClient);

const result = await shopClient.query<SearchFacetValues.Query, SearchFacetValues.Variables>(
SEARCH_GET_FACET_VALUES,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ describe('Elasticsearch plugin', () => {
},
});

await awaitRunningJobs(adminClient);

const result = await shopClient.query<SearchFacetValues.Query, SearchFacetValues.Variables>(
SEARCH_GET_FACET_VALUES,
{
Expand Down
3 changes: 2 additions & 1 deletion packages/elasticsearch-plugin/src/elasticsearch-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export class ShopElasticSearchResolver implements Omit<SearchResolver, 'reindex'
@Ctx() ctx: RequestContext,
@Parent() parent: { input: ElasticSearchInput },
): Promise<Array<{ facetValue: FacetValue; count: number }>> {
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()
Expand Down

0 comments on commit 60bb5b9

Please sign in to comment.