From bff1fb7c2dab439245a9cf01619155e0c2ae7b8e Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 6 Sep 2023 15:56:07 +0700 Subject: [PATCH 1/2] Default response content type using GraphQL spec Default response content type header should conform to [GraphQL over HTTP spec](https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md#serialization-format). --- .../graphql/runtime/SmallRyeGraphQLExecutionHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java index dd39c64ce82bf..bb7618eaefc5d 100644 --- a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java +++ b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java @@ -46,7 +46,7 @@ public class SmallRyeGraphQLExecutionHandler extends SmallRyeGraphQLAbstractHand private static final String EXTENSIONS = "extensions"; private static final String APPLICATION_GRAPHQL = "application/graphql"; private static final String OK = "OK"; - private static final String DEFAULT_RESPONSE_CONTENT_TYPE = "application/graphql+json; charset=" + private static final String DEFAULT_RESPONSE_CONTENT_TYPE = "application/graphql-response+json; charset=" + StandardCharsets.UTF_8.name(); private static final String DEFAULT_REQUEST_CONTENT_TYPE = "application/json; charset=" + StandardCharsets.UTF_8.name(); From 5550b704611ae29f4993682b2bcad8d497f6d5a0 Mon Sep 17 00:00:00 2001 From: Jan Martiska Date: Fri, 6 Oct 2023 09:14:32 +0200 Subject: [PATCH 2/2] Accept requests that ask for application/graphql-response+json --- .../graphql/runtime/SmallRyeGraphQLExecutionHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java index bb7618eaefc5d..d0ffbc1901c95 100644 --- a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java +++ b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java @@ -295,8 +295,9 @@ private static String getCharset(String mimeType) { } private boolean isValidAcceptRequest(String mimeType) { - // At this point we only accept two return mimeType.startsWith("application/json") + || mimeType.startsWith("application/graphql-response+json") + // application/graphql+json is incorrect, but we keep it for backwards compatibility || mimeType.startsWith("application/graphql+json"); }