sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [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
Date Wed, 23 Sep 2020 15:10:48 GMT
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 <cotescu@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
+}


Mime
View raw message