You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2021/05/05 17:20:21 UTC
[sling-whiteboard] branch master updated: Require suffix for query
languages
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
The following commit(s) were added to refs/heads/master by this push:
new 2f832fd Require suffix for query languages
2f832fd is described below
commit 2f832fdc47e9dba5b478287a040b753acb485965
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed May 5 19:20:08 2021 +0200
Require suffix for query languages
---
remote-content-api/sample-graphql-api/README.md | 8 +++++++-
.../sling/remotecontentapi/graphql/DocumentsDataFetcher.java | 9 ++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/remote-content-api/sample-graphql-api/README.md b/remote-content-api/sample-graphql-api/README.md
index 96186a9..cae9f83 100644
--- a/remote-content-api/sample-graphql-api/README.md
+++ b/remote-content-api/sample-graphql-api/README.md
@@ -67,8 +67,14 @@ we don't really care about the details of these node types besides their names.
}
{
+ document(path:"/open-for-all") {
+ body
+ }
+ }
+
+ {
documents(
- lang:"sql",
+ lang:"sql2020",
query:"""
select * from nt:unstructured as R
where [sling:resourceType] = 'wknd/components/carousel'
diff --git a/remote-content-api/sample-graphql-api/src/main/java/org/apache/sling/remotecontentapi/graphql/DocumentsDataFetcher.java b/remote-content-api/sample-graphql-api/src/main/java/org/apache/sling/remotecontentapi/graphql/DocumentsDataFetcher.java
index f91137d..2617f65 100644
--- a/remote-content-api/sample-graphql-api/src/main/java/org/apache/sling/remotecontentapi/graphql/DocumentsDataFetcher.java
+++ b/remote-content-api/sample-graphql-api/src/main/java/org/apache/sling/remotecontentapi/graphql/DocumentsDataFetcher.java
@@ -79,7 +79,14 @@ public class DocumentsDataFetcher implements SlingDataFetcher<Object> {
@Override
public @Nullable Object get(@NotNull SlingDataFetcherEnvironment e) throws Exception {
- final String lang = e.getArgument("lang", "xpath");
+ // Use a suffix as we might not keep these built-in language in the long term
+ final String langSuffix = "2020";
+
+ String lang = e.getArgument("lang", "xpath" + langSuffix);
+ if(!lang.endsWith(langSuffix)) {
+ throw new RuntimeException("Query langage must end with suffix " + langSuffix);
+ }
+ lang = lang.replaceAll(langSuffix + "$", "");
final String query = e.getArgument("query");
final List<Map<String, Object>> result = new ArrayList<>();