From 93817c708eea9a45bf28ae979699d903243db52d Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 29 Mar 2022 15:04:28 +0200 Subject: [PATCH] Switch to Spring for GraphQL 1.0.0-SNAPSHOT See gh-30463 --- .../GraphQlWebFluxAutoConfiguration.java | 14 +++++++------- ...GraphQlWebFluxSecurityAutoConfiguration.java | 2 +- .../GraphQlWebMvcSecurityAutoConfiguration.java | 2 +- .../servlet/GraphQlWebMvcAutoConfiguration.java | 17 ++++++++++------- .../GraphQlWebFluxAutoConfigurationTests.java | 10 +++++----- .../GraphQlWebMvcAutoConfigurationTests.java | 10 +++++----- .../spring-boot-dependencies/build.gradle | 2 +- .../graphql/GraphQlTypeExcludeFilterTests.java | 8 ++++---- 8 files changed, 34 insertions(+), 31 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java index dc145499f8..5987fe4a91 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java @@ -41,12 +41,12 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.log.LogMessage; import org.springframework.graphql.ExecutionGraphQlService; import org.springframework.graphql.execution.GraphQlSource; -import org.springframework.graphql.web.WebGraphQlHandler; -import org.springframework.graphql.web.WebGraphQlHandlerInterceptor; -import org.springframework.graphql.web.webflux.GraphQlHttpHandler; -import org.springframework.graphql.web.webflux.GraphQlWebSocketHandler; -import org.springframework.graphql.web.webflux.GraphiQlHandler; -import org.springframework.graphql.web.webflux.SchemaHandler; +import org.springframework.graphql.server.WebGraphQlHandler; +import org.springframework.graphql.server.WebGraphQlInterceptor; +import org.springframework.graphql.server.webflux.GraphQlHttpHandler; +import org.springframework.graphql.server.webflux.GraphQlWebSocketHandler; +import org.springframework.graphql.server.webflux.GraphiQlHandler; +import org.springframework.graphql.server.webflux.SchemaHandler; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -95,7 +95,7 @@ public class GraphQlWebFluxAutoConfiguration { @Bean @ConditionalOnMissingBean public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service, - ObjectProvider interceptorsProvider) { + ObjectProvider interceptorsProvider) { return WebGraphQlHandler.builder(service) .interceptors(interceptorsProvider.orderedStream().collect(Collectors.toList())).build(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebFluxSecurityAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebFluxSecurityAutoConfiguration.java index 4bc6b567a1..776c293184 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebFluxSecurityAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebFluxSecurityAutoConfiguration.java @@ -27,7 +27,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat import org.springframework.boot.autoconfigure.graphql.reactive.GraphQlWebFluxAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.graphql.execution.ReactiveSecurityDataFetcherExceptionResolver; -import org.springframework.graphql.web.webflux.GraphQlHttpHandler; +import org.springframework.graphql.server.webflux.GraphQlHttpHandler; import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebMvcSecurityAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebMvcSecurityAutoConfiguration.java index 5a3ae3cd43..a5f3bc7481 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebMvcSecurityAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebMvcSecurityAutoConfiguration.java @@ -28,7 +28,7 @@ import org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoC import org.springframework.context.annotation.Bean; import org.springframework.graphql.execution.SecurityContextThreadLocalAccessor; import org.springframework.graphql.execution.SecurityDataFetcherExceptionResolver; -import org.springframework.graphql.web.webmvc.GraphQlHttpHandler; +import org.springframework.graphql.server.webmvc.GraphQlHttpHandler; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java index 74820cdb57..e964a4ec87 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java @@ -45,12 +45,12 @@ import org.springframework.core.log.LogMessage; import org.springframework.graphql.ExecutionGraphQlService; import org.springframework.graphql.execution.GraphQlSource; import org.springframework.graphql.execution.ThreadLocalAccessor; -import org.springframework.graphql.web.WebGraphQlHandler; -import org.springframework.graphql.web.WebGraphQlHandlerInterceptor; -import org.springframework.graphql.web.webmvc.GraphQlHttpHandler; -import org.springframework.graphql.web.webmvc.GraphQlWebSocketHandler; -import org.springframework.graphql.web.webmvc.GraphiQlHandler; -import org.springframework.graphql.web.webmvc.SchemaHandler; +import org.springframework.graphql.server.WebGraphQlHandler; +import org.springframework.graphql.server.WebGraphQlInterceptor; +import org.springframework.graphql.server.webmvc.GraphQlHttpHandler; +import org.springframework.graphql.server.webmvc.GraphQlWebSocketHandler; +import org.springframework.graphql.server.webmvc.GraphiQlHandler; +import org.springframework.graphql.server.webmvc.SchemaHandler; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -87,6 +87,9 @@ public class GraphQlWebMvcAutoConfiguration { private static final Log logger = LogFactory.getLog(GraphQlWebMvcAutoConfiguration.class); + private static MediaType[] SUPPORTED_MEDIA_TYPES = new MediaType[] { MediaType.valueOf("application/graphql+json"), + MediaType.APPLICATION_JSON }; + @Bean @ConditionalOnMissingBean public GraphQlHttpHandler graphQlHttpHandler(WebGraphQlHandler webGraphQlHandler) { @@ -96,7 +99,7 @@ public class GraphQlWebMvcAutoConfiguration { @Bean @ConditionalOnMissingBean public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service, - ObjectProvider interceptorsProvider, + ObjectProvider interceptorsProvider, ObjectProvider accessorsProvider) { return WebGraphQlHandler.builder(service) .interceptors(interceptorsProvider.orderedStream().collect(Collectors.toList())) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java index 7ff15664bf..cd06337b0d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java @@ -33,10 +33,10 @@ import org.springframework.boot.test.context.runner.ReactiveWebApplicationContex import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.graphql.execution.RuntimeWiringConfigurer; -import org.springframework.graphql.web.WebGraphQlHandler; -import org.springframework.graphql.web.WebGraphQlHandlerInterceptor; -import org.springframework.graphql.web.webflux.GraphQlHttpHandler; -import org.springframework.graphql.web.webflux.GraphQlWebSocketHandler; +import org.springframework.graphql.server.WebGraphQlHandler; +import org.springframework.graphql.server.WebGraphQlInterceptor; +import org.springframework.graphql.server.webflux.GraphQlHttpHandler; +import org.springframework.graphql.server.webflux.GraphQlWebSocketHandler; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -172,7 +172,7 @@ class GraphQlWebFluxAutoConfigurationTests { static class CustomWebInterceptor { @Bean - WebGraphQlHandlerInterceptor customWebGraphQlHandlerInterceptor() { + WebGraphQlInterceptor customWebGraphQlInterceptor() { return (webInput, interceptorChain) -> interceptorChain.next(webInput) .doOnNext((output) -> output.getResponseHeaders().add("X-Custom-Header", "42")); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java index 49acfd1841..99d69aba31 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java @@ -31,10 +31,10 @@ import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.graphql.execution.RuntimeWiringConfigurer; -import org.springframework.graphql.web.WebGraphQlHandler; -import org.springframework.graphql.web.WebGraphQlHandlerInterceptor; -import org.springframework.graphql.web.webmvc.GraphQlHttpHandler; -import org.springframework.graphql.web.webmvc.GraphQlWebSocketHandler; +import org.springframework.graphql.server.WebGraphQlHandler; +import org.springframework.graphql.server.WebGraphQlInterceptor; +import org.springframework.graphql.server.webmvc.GraphQlHttpHandler; +import org.springframework.graphql.server.webmvc.GraphQlWebSocketHandler; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; @@ -183,7 +183,7 @@ class GraphQlWebMvcAutoConfigurationTests { static class CustomWebInterceptor { @Bean - WebGraphQlHandlerInterceptor customWebGraphQlHandlerInterceptor() { + WebGraphQlInterceptor customWebGraphQlInterceptor() { return (webInput, interceptorChain) -> interceptorChain.next(webInput) .doOnNext((output) -> output.getResponseHeaders().add("X-Custom-Header", "42")); } diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index ce47b26874..2e89e4fef3 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1715,7 +1715,7 @@ bom { ] } } - library("Spring GraphQL", "1.0.0-M6") { + library("Spring GraphQL", "1.0.0-SNAPSHOT") { group("org.springframework.graphql") { modules = [ "spring-graphql", diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTypeExcludeFilterTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTypeExcludeFilterTests.java index b83ebd694d..e7d5d630c3 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTypeExcludeFilterTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTypeExcludeFilterTests.java @@ -47,9 +47,9 @@ import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; import org.springframework.graphql.execution.DataFetcherExceptionResolver; import org.springframework.graphql.execution.GraphQlSource.Builder; import org.springframework.graphql.execution.RuntimeWiringConfigurer; -import org.springframework.graphql.web.WebGraphQlHandlerInterceptor; -import org.springframework.graphql.web.WebGraphQlRequest; -import org.springframework.graphql.web.WebGraphQlResponse; +import org.springframework.graphql.server.WebGraphQlInterceptor; +import org.springframework.graphql.server.WebGraphQlRequest; +import org.springframework.graphql.server.WebGraphQlResponse; import org.springframework.stereotype.Controller; import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; @@ -199,7 +199,7 @@ class GraphQlTypeExcludeFilterTests { } - static class ExampleWebInterceptor implements WebGraphQlHandlerInterceptor { + static class ExampleWebInterceptor implements WebGraphQlInterceptor { @Override public Mono intercept(WebGraphQlRequest request, Chain chain) {