diff --git a/graphql-java-spring-webflux/src/main/java/graphql/spring/web/reactive/components/GraphQLController.java b/graphql-java-spring-webflux/src/main/java/graphql/spring/web/reactive/components/GraphQLController.java index 552129f..306ef6a 100644 --- a/graphql-java-spring-webflux/src/main/java/graphql/spring/web/reactive/components/GraphQLController.java +++ b/graphql-java-spring-webflux/src/main/java/graphql/spring/web/reactive/components/GraphQLController.java @@ -62,7 +62,7 @@ public Object graphqlPOST( // "variables": { "myVariable": "someValue", ... } // } - if (MediaType.APPLICATION_JSON_VALUE.equals(contentType)) { + if (contentType != null && contentType.startsWith(MediaType.APPLICATION_JSON_VALUE)) { GraphQLRequestBody request = jsonSerializer.deserialize(body, GraphQLRequestBody.class); if (request.getQuery() == null) { request.setQuery(""); diff --git a/graphql-java-spring-webflux/src/test/java/graphql/spring/web/reactive/components/GraphQLControllerTest.java b/graphql-java-spring-webflux/src/test/java/graphql/spring/web/reactive/components/GraphQLControllerTest.java index ea57695..4f482b7 100644 --- a/graphql-java-spring-webflux/src/test/java/graphql/spring/web/reactive/components/GraphQLControllerTest.java +++ b/graphql-java-spring-webflux/src/test/java/graphql/spring/web/reactive/components/GraphQLControllerTest.java @@ -64,7 +64,7 @@ public void testPostRequest() throws Exception { Mockito.when(graphql.executeAsync(captor.capture())).thenReturn(cf); client.post().uri("/graphql") - .contentType(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON_UTF8) .body(Mono.just(request), Map.class) .accept(MediaType.APPLICATION_JSON_UTF8) .exchange() @@ -93,7 +93,7 @@ public void testSimplePostRequest() throws Exception { Mockito.when(graphql.executeAsync(captor.capture())).thenReturn(cf); client.post().uri("/graphql") - .contentType(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON_UTF8) .body(Mono.just(request), Map.class) .accept(MediaType.APPLICATION_JSON_UTF8) .exchange() diff --git a/graphql-java-spring-webmvc/src/main/java/graphql/spring/web/servlet/components/GraphQLController.java b/graphql-java-spring-webmvc/src/main/java/graphql/spring/web/servlet/components/GraphQLController.java index 9935b68..1ccd064 100644 --- a/graphql-java-spring-webmvc/src/main/java/graphql/spring/web/servlet/components/GraphQLController.java +++ b/graphql-java-spring-webmvc/src/main/java/graphql/spring/web/servlet/components/GraphQLController.java @@ -63,7 +63,7 @@ public Object graphqlPOST( // "variables": { "myVariable": "someValue", ... } // } - if (MediaType.APPLICATION_JSON_VALUE.equals(contentType)) { + if (contentType != null && contentType.startsWith(MediaType.APPLICATION_JSON_VALUE)) { GraphQLRequestBody request = jsonSerializer.deserialize(body, GraphQLRequestBody.class); if (request.getQuery() == null) { request.setQuery(""); diff --git a/graphql-java-spring-webmvc/src/test/java/graphql/spring/web/servlet/components/GraphQLControllerTest.java b/graphql-java-spring-webmvc/src/test/java/graphql/spring/web/servlet/components/GraphQLControllerTest.java index 3594d8c..88a7e1f 100644 --- a/graphql-java-spring-webmvc/src/test/java/graphql/spring/web/servlet/components/GraphQLControllerTest.java +++ b/graphql-java-spring-webmvc/src/test/java/graphql/spring/web/servlet/components/GraphQLControllerTest.java @@ -86,7 +86,7 @@ public void testPostRequest() throws Exception { MvcResult mvcResult = this.mockMvc.perform(post("/graphql") .content(toJson(request)) - .contentType(MediaType.APPLICATION_JSON)) + .contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()) .andExpect(request().asyncStarted()) .andReturn(); @@ -121,7 +121,7 @@ public void testSimplePostRequest() throws Exception { MvcResult mvcResult = this.mockMvc.perform(post("/graphql") .content(toJson(request)) - .contentType(MediaType.APPLICATION_JSON)) + .contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()) .andExpect(request().asyncStarted()) .andReturn();