From 36bfd40d66494987931d68142a0e26b6f7d156c2 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 13 Jan 2025 11:47:09 +0100 Subject: [PATCH] Remove usages of Framework's MediaType.APPLICATION_GRAPHQL Closes gh-1109 --- .../graphql/client/HttpGraphQlTransport.java | 10 ++++------ .../graphql/server/webflux/GraphQlHttpHandler.java | 8 +++++--- .../graphql/server/webmvc/GraphQlHttpHandler.java | 8 +++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/HttpGraphQlTransport.java b/spring-graphql/src/main/java/org/springframework/graphql/client/HttpGraphQlTransport.java index c5bc7009..611e34f0 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/HttpGraphQlTransport.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/HttpGraphQlTransport.java @@ -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>> SSE_TYPE = new ParameterizedTypeReference>>() { }; - // 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 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) { diff --git a/spring-graphql/src/main/java/org/springframework/graphql/server/webflux/GraphQlHttpHandler.java b/spring-graphql/src/main/java/org/springframework/graphql/server/webflux/GraphQlHttpHandler.java index a3cc3d33..537f3e0d 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/server/webflux/GraphQlHttpHandler.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/server/webflux/GraphQlHttpHandler.java @@ -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 SUPPORTED_MEDIA_TYPES = List.of( - MediaType.APPLICATION_GRAPHQL_RESPONSE, MediaType.APPLICATION_JSON, MediaType.APPLICATION_GRAPHQL); + MediaType.APPLICATION_GRAPHQL_RESPONSE, MediaType.APPLICATION_JSON, APPLICATION_GRAPHQL); /** diff --git a/spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlHttpHandler.java b/spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlHttpHandler.java index 80a59655..9b35a556 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlHttpHandler.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlHttpHandler.java @@ -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 SUPPORTED_MEDIA_TYPES = List.of( - MediaType.APPLICATION_GRAPHQL_RESPONSE, MediaType.APPLICATION_JSON, MediaType.APPLICATION_GRAPHQL); + MediaType.APPLICATION_GRAPHQL_RESPONSE, MediaType.APPLICATION_JSON, APPLICATION_GRAPHQL); /**