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/06/11 12:55:24 UTC

[sling-whiteboard] branch master updated: Next steps in README + forgot to commit the ObjectScalar

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 c4f0a93  Next steps in README + forgot to commit the ObjectScalar
c4f0a93 is described below

commit c4f0a9309c38fd1ea346982a0f8bc9081ec132fd
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jun 11 14:55:01 2021 +0200

    Next steps in README + forgot to commit the ObjectScalar
---
 remote-content-api/sample-graphql-api/README.md    | 18 +++++++++
 .../samples/graphql/ObjectScalar.java              | 45 ++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/remote-content-api/sample-graphql-api/README.md b/remote-content-api/sample-graphql-api/README.md
index 964072d..318984c 100644
--- a/remote-content-api/sample-graphql-api/README.md
+++ b/remote-content-api/sample-graphql-api/README.md
@@ -24,6 +24,24 @@ The standard `MAVEN_OPTS` environment variable can be used to setup
 debugging, as the above does not fork and starts the application with
 the Maven JVM.
 
+## Next Steps
+Here are a few ideas in no specific order.
+
+Uppercase selectors in these notes refer to the _API planes_ concept, where the first uppercase selector addresses an "API plane" where
+specific functionality is available, usually with a specific GraphQL Schema. The term "plane" is similar to a geometric plane, it's not
+about flying metal tubes.
+
+* Fix https://issues.apache.org/jira/browse/SLING-10485 to better support **various input types in Mutations**.
+* Implement a small **content tree manipulation language** for the Command mutation. On a new API plane "C"? Can use a restricted variant of the repoinit language with just "create path" and "set ACL" along with delete and move operations. Provides similar functionality to the [Sling Post Servlet](https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html) in a more discoverable and especially strictly controlled way.
+* Implement a **restrictive HTTP proxy to the Sling POST servlet** for updating content. On a new API plane "U"? For "updates". Might be restricted to the default "update content" operation and only if the target is either a Document or a Folder which can contain Documents. Other content manipulations are performed with the above content tree manipulation language, in order to restrict and better control them. POSTing content to that servlet can also happen with a GraphQL Mutation, we mi [...]
+* Provide **hyperlinks to the various API planes** and/or explanations of how they work as part of the "links" field of Folders and Documents.
+* Maybe rename the N plane to D as in "developement"?
+* Add support for **selector-driven stored queries** so that `/content.P.folders.json` for example executes the 'folders' query that's been developed and stored from that developers plane. The P plane is for publishing, where HTTP GET requests return cacheable content based on stored queries.
+* Add tests (using [Karate](https://github.com/intuit/karate)?) to this module to demonstrate the APIs if it looks like the module will graduate to a full-fledged Sling module. So far it's only tested interactively using the below example queries.
+
+The overall idea is that accessing `/content.N.json` with a GraphQL client should be sufficient for a developer
+to discover everything, via the commented GraphQL Schema provided there.
+
 ## Test Content
 
 The test content uses `com.adobe.aem.guides:aem-guides-wknd.ui.content.sample` which is MIT
diff --git a/remote-content-api/sample-graphql-api/src/main/java/org/apache/sling/remotecontent/samples/graphql/ObjectScalar.java b/remote-content-api/sample-graphql-api/src/main/java/org/apache/sling/remotecontent/samples/graphql/ObjectScalar.java
new file mode 100644
index 0000000..1e8b9a2
--- /dev/null
+++ b/remote-content-api/sample-graphql-api/src/main/java/org/apache/sling/remotecontent/samples/graphql/ObjectScalar.java
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+/** Object Scalar, used to handle any data type */
+@Component(service = SlingScalarConverter.class, property = { "name=Object" })
+public class ObjectScalar implements SlingScalarConverter<Object, Object> {
+
+    @Override
+    public @Nullable Object parseValue(@Nullable Object input) throws ScalarConversionException {
+        // TODO validate and convert the input value - if we want to keep hiding the graphql-java APIs
+        // we'll need the GraphQL Core to convert the input to the appropriate class
+        return input;
+    }
+
+    @Override
+    public @Nullable Object serialize(@Nullable Object value) throws ScalarConversionException {
+        // TODO validate and convert the value - if we want to keep hiding the graphql-java APIs
+        // we'll need the GraphQL Core to convert the input to the appropriate class
+        return value;
+    }
+
+}
\ No newline at end of file