Remove usages of Framework's MediaType.APPLICATION_GRAPHQL

Closes gh-1109
This commit is contained in:
Brian Clozel
2025-01-13 11:47:09 +01:00
parent ff0528611e
commit 36bfd40d66
3 changed files with 14 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,9 +48,8 @@ final class HttpGraphQlTransport implements GraphQlTransport {
private static final ParameterizedTypeReference<ServerSentEvent<Map<String, Object>>> SSE_TYPE =
new ParameterizedTypeReference<ServerSentEvent<Map<String, Object>>>() { };
// To be removed in favor of Framework's MediaType.APPLICATION_GRAPHQL_RESPONSE
private static final MediaType APPLICATION_GRAPHQL_RESPONSE =
new MediaType("application", "graphql-response+json");
private static final MediaType APPLICATION_GRAPHQL =
new MediaType("application", "graphql+json");
private final WebClient webClient;
@@ -73,11 +72,10 @@ final class HttpGraphQlTransport implements GraphQlTransport {
@Override
@SuppressWarnings("removal")
public Mono<GraphQlResponse> execute(GraphQlRequest request) {
return this.webClient.post()
.contentType(this.contentType)
.accept(MediaType.APPLICATION_JSON, APPLICATION_GRAPHQL_RESPONSE, MediaType.APPLICATION_GRAPHQL)
.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_GRAPHQL_RESPONSE, APPLICATION_GRAPHQL)
.bodyValue(request.toMap())
.attributes((attributes) -> {
if (request instanceof ClientGraphQlRequest clientRequest) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2024 the original author or authors.
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,9 +36,11 @@ import org.springframework.web.reactive.function.server.ServerResponse;
*/
public class GraphQlHttpHandler extends AbstractGraphQlHttpHandler {
@SuppressWarnings("removal")
private static final MediaType APPLICATION_GRAPHQL =
new MediaType("application", "graphql+json");
private static final List<MediaType> SUPPORTED_MEDIA_TYPES = List.of(
MediaType.APPLICATION_GRAPHQL_RESPONSE, MediaType.APPLICATION_JSON, MediaType.APPLICATION_GRAPHQL);
MediaType.APPLICATION_GRAPHQL_RESPONSE, MediaType.APPLICATION_JSON, APPLICATION_GRAPHQL);
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2024 the original author or authors.
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,9 +41,11 @@ import org.springframework.web.servlet.function.ServerResponse;
*/
public class GraphQlHttpHandler extends AbstractGraphQlHttpHandler {
@SuppressWarnings("removal")
private static final MediaType APPLICATION_GRAPHQL =
new MediaType("application", "graphql+json");
private static final List<MediaType> SUPPORTED_MEDIA_TYPES = List.of(
MediaType.APPLICATION_GRAPHQL_RESPONSE, MediaType.APPLICATION_JSON, MediaType.APPLICATION_GRAPHQL);
MediaType.APPLICATION_GRAPHQL_RESPONSE, MediaType.APPLICATION_JSON, APPLICATION_GRAPHQL);
/**