Do not use application/graphql as default MIME type

As seen in spring-projects/spring-graphql#375, Spring Boot should also
use "application/json" as the default MIME type but remain compatible
with "application/graphql+json" still if clients POST content with this
type or explicitly accept it.

Closes gh-30860
This commit is contained in:
Brian Clozel
2022-05-04 13:04:14 +02:00
parent 31cabba828
commit 5352c441e1
5 changed files with 7 additions and 7 deletions

View File

@@ -79,7 +79,7 @@ class HttpGraphQlTesterContextCustomizerIntegrationTests {
@Override
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
response.setStatusCode(HttpStatus.OK);
response.getHeaders().setContentType(MediaType.APPLICATION_GRAPHQL);
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
return response.writeWith(Mono.just(factory.wrap("{\"data\":{}}".getBytes())));
}

View File

@@ -79,7 +79,7 @@ class HttpGraphQlTesterContextCustomizerWithCustomBasePathTests {
@Override
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
response.setStatusCode(HttpStatus.OK);
response.getHeaders().setContentType(MediaType.APPLICATION_GRAPHQL);
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
return response.writeWith(Mono.just(factory.wrap("{\"data\":{}}".getBytes())));
}

View File

@@ -70,7 +70,7 @@ class HttpGraphQlTesterContextCustomizerWithCustomContextPathTests {
@RestController
static class TestController {
@PostMapping(path = "/graphql", produces = MediaType.APPLICATION_GRAPHQL_VALUE)
@PostMapping(path = "/graphql", produces = MediaType.APPLICATION_JSON_VALUE)
String graphql() {
return "{}";
}