From b39ee28c60542cdce16a330de38fddc2935f1cb0 Mon Sep 17 00:00:00 2001 From: ResuBaka Date: Tue, 15 Oct 2019 15:21:24 +0200 Subject: [PATCH 1/4] Fixed error around sort option in graphql --- core/lib/search/adapter/graphql/gqlQuery.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/lib/search/adapter/graphql/gqlQuery.js b/core/lib/search/adapter/graphql/gqlQuery.js index 0bb90a660e..c065a36689 100644 --- a/core/lib/search/adapter/graphql/gqlQuery.js +++ b/core/lib/search/adapter/graphql/gqlQuery.js @@ -45,7 +45,11 @@ export function prepareQueryVars (Request) { if (Request.sort !== '') { const sortParse = Request.sort.split(':') - queryVariables.sort[sortParse[0]] = sortParse[1].toUpperCase() + if (sortParse[1] !== undefined) { + queryVariables.sort[sortParse[0]] = sortParse[1].toUpperCase() + } else { + queryVariables.sort[sortParse[0]] = 'ASC' + } } queryVariables.pageSize = Request.size From 28d1fed57091683e1d7ca9500d098d1a239b5c25 Mon Sep 17 00:00:00 2001 From: ResuBaka Date: Tue, 15 Oct 2019 15:22:01 +0200 Subject: [PATCH 2/4] Added in to cmsBlock items response in graphql --- core/lib/search/adapter/graphql/queries/cmsBlock.gql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/lib/search/adapter/graphql/queries/cmsBlock.gql b/core/lib/search/adapter/graphql/queries/cmsBlock.gql index 74f5b6531a..e9cdb49214 100644 --- a/core/lib/search/adapter/graphql/queries/cmsBlock.gql +++ b/core/lib/search/adapter/graphql/queries/cmsBlock.gql @@ -5,9 +5,10 @@ query cmsBlocks ($filter: CmsInput) { { items { title + id identifier content creation_time } } -} \ No newline at end of file +} From 0627ab29210940e5eb9721f0e94ab00608ee7138 Mon Sep 17 00:00:00 2001 From: ResuBaka Date: Tue, 15 Oct 2019 15:24:34 +0200 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98435d2516..bb42fb2920 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed handling checkbox custom option - @gibkigonzo (#2781) - Fixed typos in docs - @afozbek (#3709) - Fixed VSF build fails for some people due to lack of dependencies in the container - @krskibin (#3699) +- Fixed two graphql problems, one with cms_blocks and the other with default sort order - @resubaka (#3718) ### Added - Added support for ES7 - @andrzejewsky (#3690) From a084ebc663b4859f976c18d74d6db388b53a0a59 Mon Sep 17 00:00:00 2001 From: ResuBaka Date: Wed, 16 Oct 2019 06:35:05 +0200 Subject: [PATCH 4/4] Small fix to default sort order of _score As _score needs to be default DESC and not ASC we need to check if the sort key is _score or not. --- core/lib/search/adapter/graphql/gqlQuery.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/lib/search/adapter/graphql/gqlQuery.js b/core/lib/search/adapter/graphql/gqlQuery.js index c065a36689..80595a9f7d 100644 --- a/core/lib/search/adapter/graphql/gqlQuery.js +++ b/core/lib/search/adapter/graphql/gqlQuery.js @@ -48,7 +48,11 @@ export function prepareQueryVars (Request) { if (sortParse[1] !== undefined) { queryVariables.sort[sortParse[0]] = sortParse[1].toUpperCase() } else { - queryVariables.sort[sortParse[0]] = 'ASC' + if (sortParse[0] === '_score') { + queryVariables.sort[sortParse[0]] = 'DESC' + } else { + queryVariables.sort[sortParse[0]] = 'ASC' + } } }