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 c42b2d4  Resource-specific schemas
c42b2d4 is described below

commit c42b2d41ea0f1315ba46aa7d545528fcacb07124
Author: Bertrand Delacretaz <[email protected]>
AuthorDate: Fri May 8 14:01:38 2020 +0200

    Resource-specific schemas
---
 graphql-scripting/README.md | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/graphql-scripting/README.md b/graphql-scripting/README.md
index 44a6e6c..24b81ca 100644
--- a/graphql-scripting/README.md
+++ b/graphql-scripting/README.md
@@ -25,7 +25,30 @@ This module enables the following GraphQL "styles"
     server-side "**prepared GraphQL queries**" and the more traditional 
client-supplied queries.
     
 The GraphQL requests can hit a Sling resource in all cases, there's no need 
for path-mounted servlets which are [not 
desirable](https://sling.apache.org/documentation/the-sling-engine/servlets.html#caveats-when-binding-servlets-by-path-1).
+
+## Resource-specific GraphQL schemas
+
+Schemas are provided by `SchemaProvider` services:
+
+    public interface SchemaProvider {
   
+      /** Get a GraphQL Schema definition for the given resource and optional 
selectors
+       *
+       *  @param r The Resource to which the schema applies
+       *  @param selectors Optional set of Request Selectors that can 
influence the schema selection
+       *  @return a GraphQL schema that can be annotated to define the data 
fetchers to use, see
+       *      this module's documentation. Can return null if a schema cannot 
be provided, in which
+       *      case a different provider should be used.
+       */
+      @Nullable
+      String getSchema(@NotNull Resource r, @Nullable String [] selectors) 
throws IOException;
+    }
+
+The default provider makes an internal Sling request with for the current 
Resource with a `.GQLschema` extension.
+
+This allows the Sling script/servlet resolution mechanism and its script 
engines to be used to generate 
+schemas dynamically, taking request selectors into account.
+
 ## DataFetcher selection with Schema annotations
 
 The GraphQL schemas used by this module can be enhanced with comments
@@ -93,4 +116,4 @@ And then install this bundle using for example
     mvn clean install sling:install
 
 For some reason, as of April 14th the 
`org.apache.sling.installer.factory.packages` bundle
-has to be stopped for this to work - didn't investigate so far.
\ No newline at end of file
+has to be stopped for this to work - didn't investigate so far.

Reply via email to