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:01:46 UTC

[sling-whiteboard] branch master updated: multiple 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 be4c38b  multiple query languages
be4c38b is described below

commit be4c38b6ae6e28995af9917a68efc81e7e8541db
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed May 5 19:01:28 2021 +0200

    multiple query languages
---
 remote-content-api/sample-graphql-api/README.md             | 13 +++++++++++++
 .../remotecontentapi/graphql/DocumentsDataFetcher.java      |  3 ++-
 .../initial-content/apps/samples/graphql/GQLschema.jsp      |  2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/remote-content-api/sample-graphql-api/README.md b/remote-content-api/sample-graphql-api/README.md
index 4e38eb8..96186a9 100644
--- a/remote-content-api/sample-graphql-api/README.md
+++ b/remote-content-api/sample-graphql-api/README.md
@@ -65,3 +65,16 @@ we don't really care about the details of these node types besides their names.
         output
       }
     }
+
+    {
+      documents(
+        lang:"sql",
+        query:"""
+          select * from nt:unstructured as R
+          where [sling:resourceType] = 'wknd/components/carousel'
+          and isdescendantnode(R, '/content/wknd/us/en')
+        """) 
+       {
+        path
+      }
+    }
\ No newline at end of file
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 55a9da6..f91137d 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,11 +79,12 @@ public class DocumentsDataFetcher implements SlingDataFetcher<Object> {
     
     @Override
     public @Nullable Object get(@NotNull SlingDataFetcherEnvironment e) throws Exception {
+        final String lang = e.getArgument("lang", "xpath");
         final String query = e.getArgument("query");
         final List<Map<String, Object>> result = new ArrayList<>();
 
         final ResourceResolver resolver = e.getCurrentResource().getResourceResolver();
-        final Iterator<Resource> it = resolver.findResources(query, "xpath");
+        final Iterator<Resource> it = resolver.findResources(query, lang);
         while(it.hasNext()) {
             result.add(toDocument(it.next()));
         }
diff --git a/remote-content-api/sample-graphql-api/src/main/resources/SLING-INF/initial-content/apps/samples/graphql/GQLschema.jsp b/remote-content-api/sample-graphql-api/src/main/resources/SLING-INF/initial-content/apps/samples/graphql/GQLschema.jsp
index 9997cba..7539aa4 100644
--- a/remote-content-api/sample-graphql-api/src/main/resources/SLING-INF/initial-content/apps/samples/graphql/GQLschema.jsp
+++ b/remote-content-api/sample-graphql-api/src/main/resources/SLING-INF/initial-content/apps/samples/graphql/GQLschema.jsp
@@ -23,7 +23,7 @@ scalar Object
 
 type Query {
   document(path : String, selectors : [String]) : Document @fetcher(name:"samples/document")
-  documents(query : String, selectors : [String]) : [Document] @fetcher(name:"samples/documents")
+  documents(lang: String, query : String, selectors : [String]) : [Document] @fetcher(name:"samples/documents")
 }
 
 type Mutation {