Support application/graphql+json content type

The GraphQL HTTP spec now requires the `"application/graphql+json"`
content type.
This commit applies this type by default in the server and client
implementations. `"application/json"` is still accepted and produced if
requested by clients.

Closes gh-108
This commit is contained in:
Brian Clozel
2022-04-04 13:34:18 +02:00
parent 2cdaf344fc
commit e455ebb3d8
9 changed files with 117 additions and 19 deletions

View File

@@ -55,12 +55,12 @@ final class WebTestClientTransport implements GraphQlTransport {
public Mono<GraphQlResponse> execute(GraphQlRequest request) {
Map<String, Object> responseMap = this.webTestClient.post()
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_GRAPHQL)
.accept(MediaType.APPLICATION_GRAPHQL)
.bodyValue(request.toMap())
.exchange()
.expectStatus().isOk()
.expectHeader().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)
.expectHeader().contentTypeCompatibleWith(MediaType.APPLICATION_GRAPHQL)
.expectBody(MAP_TYPE)
.returnResult()
.getResponseBody();