You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2020/09/23 15:10:48 UTC

[sling-org-apache-sling-graphql-core] branch master updated: SLING-9763 - Use the "application/graphql" mime type for the org.apache.sling.graphql.core.scripting.GraphQLScriptEngineFactory

This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-graphql-core.git


The following commit(s) were added to refs/heads/master by this push:
     new c3a176f  SLING-9763 - Use the "application/graphql" mime type for the org.apache.sling.graphql.core.scripting.GraphQLScriptEngineFactory
c3a176f is described below

commit c3a176fceb93460797bb243e55f7d011fc45e2c6
Author: Radu Cotescu <co...@adobe.com>
AuthorDate: Wed Sep 23 17:10:23 2020 +0200

    SLING-9763 - Use the "application/graphql" mime type for the org.apache.sling.graphql.core.scripting.GraphQLScriptEngineFactory
---
 .../scripting/GraphQLScriptEngineFactoryConfiguration.java |  7 +++++--
 .../sling/graphql/core/it/GraphQLScriptEngineIT.java       | 14 ++++++++++----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/graphql/core/scripting/GraphQLScriptEngineFactoryConfiguration.java b/src/main/java/org/apache/sling/graphql/core/scripting/GraphQLScriptEngineFactoryConfiguration.java
index 1f99167..23586ac 100644
--- a/src/main/java/org/apache/sling/graphql/core/scripting/GraphQLScriptEngineFactoryConfiguration.java
+++ b/src/main/java/org/apache/sling/graphql/core/scripting/GraphQLScriptEngineFactoryConfiguration.java
@@ -40,8 +40,11 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition;
         description = "mime types"
     )
     String[] mimeTypes() default {
-        // TODO just making this up, is there a standard value?
-        "text/x-graphql"
+        /*
+        see https://graphql.org/learn/serving-over-http/ where it is documented that a request using the "application/graphql"
+        content-type should be treated as a raw GraphQL query
+         */
+        "application/graphql"
     };
 
     @AttributeDefinition(
diff --git a/src/test/java/org/apache/sling/graphql/core/it/GraphQLScriptEngineIT.java b/src/test/java/org/apache/sling/graphql/core/it/GraphQLScriptEngineIT.java
index b5ce39b..fc72d39 100644
--- a/src/test/java/org/apache/sling/graphql/core/it/GraphQLScriptEngineIT.java
+++ b/src/test/java/org/apache/sling/graphql/core/it/GraphQLScriptEngineIT.java
@@ -41,7 +41,11 @@ public class GraphQLScriptEngineIT extends GraphQLCoreTestSupport {
 
     @Inject
     @Filter(value = "(names=graphql)")
-    protected ScriptEngineFactory scriptEngineFactory;
+    protected ScriptEngineFactory graphQLScriptEngine;
+
+    @Inject
+    @Filter(value = "(mimeTypes=application/graphql)")
+    protected ScriptEngineFactory graphQLScriptEngineByMimeType;
 
     @Configuration
     public Option[] configuration() {
@@ -50,9 +54,11 @@ public class GraphQLScriptEngineIT extends GraphQLCoreTestSupport {
 
     @Test
     public void testEnginePresent() throws ScriptException {
-        assertNotNull("Expecting ScriptEngineFactory to be present", scriptEngineFactory);
-        final ScriptEngine engine = scriptEngineFactory.getScriptEngine();
+        assertNotNull("Expecting ScriptEngineFactory to be present", graphQLScriptEngine);
+        final ScriptEngine engine = graphQLScriptEngine.getScriptEngine();
         assertNotNull("Expecting ScriptEngine to be provided", engine);
         assertEquals("Expecting our GraphQLScriptEngine", "GraphQLScriptEngine", engine.getClass().getSimpleName());
+        assertEquals("Expected to get the GraphQLScriptEngine when filtering by mime type.", graphQLScriptEngine,
+                graphQLScriptEngineByMimeType);
     }
-}
\ No newline at end of file
+}