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 2020/04/17 14:40:35 UTC

[sling-whiteboard] branch master updated: README about DataFetcher definitions

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 0c9db2d  README about DataFetcher definitions
0c9db2d is described below

commit 0c9db2d0e202eb74b605e65da7bfe01b4a8818f8
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Apr 17 16:35:39 2020 +0200

    README about DataFetcher definitions
---
 graphql-scripting/README.md | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/graphql-scripting/README.md b/graphql-scripting/README.md
index 2d7424d..2e3f8df 100644
--- a/graphql-scripting/README.md
+++ b/graphql-scripting/README.md
@@ -19,12 +19,41 @@ implement any suitable dynamic mechanism to provide it.
 
 ----
 
-## Next Steps
+## Decorating the schemas with DataFetcher definitions
+
+With dynamic schemas, I think the mapping of types and/or fields to DataFetchers belongs in them.
+
+We can use structured comments in the schemas for this so that they stay syntactically valid.
+
+Here's an example where `## fetch:` comments are used for these definitions:
+
+    type Query {
+
+      # Use the 'test:pipe' Fetcher where "test" is a Fetcher namespace,
+      # and pass "$" to it as a data selection expression which in this
+      # case means "use the current Sling Resource".
+      currentResource : SlingResource ## fetch:test/pipe $
+
+    }
+
+    type SlingResource {
+      path: String
+      resourceType: String
+
+      # Use the "test:digest" DataFetcher with the "md5" fetcher option
+      # and pass "$path" as its data selection expression
+      pathMD5: String ## fetch:test/digest/md5 $.path
+
+      # Similar with different fetcher options
+      pathSHA512: String ## fetch:test/digest/sha512,armored(UTF-8) $.path
+    }
+
+A default `DataFetcher` is used for types and fields which have no `## fetch:` comment.
+
+This is **not yet implemented** at commit 25cbb95d, there's just a basic parser for the above
+fetch definitions.
+
 
-  * This is just a rough prototype for now, in "the tests are green, who cares?" style. 
-  * We'll probably need to invent a way to specify which `DataFetchers` to use in the schemas, for example decorating 
-    them with information on how to select a suitable `DataFetchers` OSGi service based on service properties.
-  
 ## Multiple GraphQL endpoint styles
 
 This module enables the following GraphQL "styles"