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 c1c930e  It's really an Object scalar, not specific to JSON
c1c930e is described below

commit c1c930ea12a9a3e6496da307fc15dec10a6f5563
Author: Bertrand Delacretaz <bdelacre...@apache.org>
AuthorDate: Fri Jun 11 14:18:09 2021 +0200

    It's really an Object scalar, not specific to JSON
---
 remote-content-api/sample-graphql-api/README.md    | 51 +++++++++++++++++++---
 .../remotecontent/samples/graphql/JsonScalar.java  | 41 -----------------
 .../main/resources/schemas/default/N.GQLschema.jsp | 11 +++--
 3 files changed, 53 insertions(+), 50 deletions(-)

diff --git a/remote-content-api/sample-graphql-api/README.md 
b/remote-content-api/sample-graphql-api/README.md
index 2281c5a..964072d 100644
--- a/remote-content-api/sample-graphql-api/README.md
+++ b/remote-content-api/sample-graphql-api/README.md
@@ -3,8 +3,6 @@
 This sample provides a GraphQL query and command API that uses the sibling 
`document-aggregator` module
 to output complete documents that aim to provide everything that's required to 
render a given Sling resource.
 
-As I write this it doesn't use the SLING-10309 GraphQL pagination features 
yet, but it should.
-
 To start this, build the sibling modules with `mvn clean install` in the 
parent folder
 of this one and then, in this folder, run
 
@@ -113,7 +111,7 @@ This prototype is evolving, some of these examples might be 
out of date. See the
     }
 
     {
-      documents(query: "//content/*/*") {
+      documents(query: "//content/wknd/us/*/*") {
         edges {
           node {
             path
@@ -172,7 +170,7 @@ This prototype is evolving, some of these examples might be 
out of date. See the
     }
 
     mutation {
-      command(lang: "echo", input: "Just a string") {
+      command(lang: "echo", input: "Just a string, could also be an Integer, 
Float, Boolean, Array etc.") {
         success
         output
         help
@@ -207,4 +205,47 @@ This prototype is evolving, some of these examples might 
be out of date. See the
           }
         }
       }
-    }
\ No newline at end of file
+    }
+
+    {
+      document(path: "/content/articles") {
+        path
+        backstage {
+          authoring {
+            content
+          }
+        }
+      }
+      folder {
+        path
+      }
+      folders(path: "/content/wknd/") {
+        edges {
+          node {
+            path
+          }
+        }
+      }
+      documents(query: "//content/wknd/us/*/*") {
+        edges {
+          node {
+            path
+            header {
+              parent
+              resourceType
+              resourceSuperType
+            }
+            body {
+              source
+              content
+            }
+            backstage {
+              authoring {
+                source
+                content
+              }
+            }
+          }
+        }
+      }
+    }
diff --git 
a/remote-content-api/sample-graphql-api/src/main/java/org/apache/sling/remotecontent/samples/graphql/JsonScalar.java
 
b/remote-content-api/sample-graphql-api/src/main/java/org/apache/sling/remotecontent/samples/graphql/JsonScalar.java
deleted file mode 100644
index 1bcc434..0000000
--- 
a/remote-content-api/sample-graphql-api/src/main/java/org/apache/sling/remotecontent/samples/graphql/JsonScalar.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sling.remotecontent.samples.graphql;
-
-import org.apache.sling.graphql.api.ScalarConversionException;
-import org.apache.sling.graphql.api.SlingScalarConverter;
-import org.jetbrains.annotations.Nullable;
-import org.osgi.service.component.annotations.Component;
-
-/** Passthrough Scalar, used to handle unpredictable JSON structures */
-@Component(service = SlingScalarConverter.class, property = { "name=JSON" })
-public class JsonScalar implements SlingScalarConverter<Object, Object> {
-
-    @Override
-    public @Nullable Object parseValue(@Nullable Object input) throws 
ScalarConversionException {
-        return input;
-    }
-
-    @Override
-    public @Nullable Object serialize(@Nullable Object value) throws 
ScalarConversionException {
-        return value;
-    }
-
-}
\ No newline at end of file
diff --git 
a/remote-content-api/sample-graphql-api/src/main/resources/schemas/default/N.GQLschema.jsp
 
b/remote-content-api/sample-graphql-api/src/main/resources/schemas/default/N.GQLschema.jsp
index 9bdf71c..1799f6b 100644
--- 
a/remote-content-api/sample-graphql-api/src/main/resources/schemas/default/N.GQLschema.jsp
+++ 
b/remote-content-api/sample-graphql-api/src/main/resources/schemas/default/N.GQLschema.jsp
@@ -25,8 +25,9 @@ create a "text passthrough" script engine for such things.
 
 """
 Some fields use this Scalar to provide unstructured or semi-structured data
+TODO we might need a specific type for JSON input and output
 """
-scalar JSON
+scalar Object
 
 type Query {
   """ 
@@ -108,7 +109,7 @@ such as Resource Type values help make such structures 
self-descriptive.
 type UnstructuredContent {
   name : String!
   source : String!
-  content : JSON
+  content : Object
 }
 
 """
@@ -146,7 +147,7 @@ type Mutation {
   'lang' is the command language - TODO provide a query that lists languages 
with their help text
   'script' is the script to execute, in the language indicated by 'lang'
   """  
-  command(lang: String, input: JSON) : CommandResult 
@fetcher(name:"samples/command")
+  command(lang: String, input: Object) : CommandResult 
@fetcher(name:"samples/command")
 }
 
 """
@@ -156,7 +157,9 @@ type CommandResult {
   """ true if the command was successful (TODO use status/error codes?) """
   success: Boolean!
 
-  """ The command output, as text """
+  """ The command output, Object or String """
+  # TODO should be of type Object, but the ObjectScalar doesn't
+  # properly convert JSON input yet
   output: String
 
   """ Optional help text for this command """

Reply via email to