From 68806bfef851e28accc99fe839ae4c1651b242cc Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 14 Jan 2022 21:05:15 +0100 Subject: [PATCH] Fix build after Spring for GraphQL changes See spring-projects/spring-graphql#244 --- .../data/GraphQlQuerydslAutoConfiguration.java | 14 +++++++------- .../GraphQlReactiveQuerydslAutoConfiguration.java | 9 +++++---- .../graphql/GraphQlAutoConfigurationTests.java | 7 ++++++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslAutoConfiguration.java index d10c0dcab0..73039e65d5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -16,7 +16,6 @@ package org.springframework.boot.autoconfigure.graphql.data; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -43,8 +42,9 @@ import org.springframework.graphql.execution.GraphQlSource; * matching return type. * * @author Rossen Stoyanchev + * @author Brian Clozel * @since 2.7.0 - * @see QuerydslDataFetcher#autoRegistrationTypeVisitor(List, List) + * @see QuerydslDataFetcher#autoRegistrationConfigurer(List, List) */ @Configuration(proxyBeanMethods = false) @ConditionalOnClass({ GraphQL.class, QuerydslDataFetcher.class, QuerydslPredicateExecutor.class }) @@ -59,11 +59,11 @@ public class GraphQlQuerydslAutoConfiguration { return (builder) -> { List> executors = executorsProvider.stream().collect(Collectors.toList()); - List> reactiveExecutors = reactiveExecutorsProvider.stream() - .collect(Collectors.toList()); if (!executors.isEmpty()) { - builder.typeVisitors(Collections - .singletonList(QuerydslDataFetcher.autoRegistrationTypeVisitor(executors, reactiveExecutors))); + List> reactiveExecutors = reactiveExecutorsProvider.stream() + .collect(Collectors.toList()); + builder.configureRuntimeWiring( + QuerydslDataFetcher.autoRegistrationConfigurer(executors, reactiveExecutors)); } }; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQuerydslAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQuerydslAutoConfiguration.java index 91b5689855..1b5a46fb05 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQuerydslAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQuerydslAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -42,8 +42,9 @@ import org.springframework.graphql.execution.GraphQlSource; * matching return type. * * @author Rossen Stoyanchev + * @author Brian Clozel * @since 2.7.0 - * @see QuerydslDataFetcher#autoRegistrationTypeVisitor(List, List) + * @see QuerydslDataFetcher#autoRegistrationConfigurer(List, List) */ @Configuration(proxyBeanMethods = false) @ConditionalOnClass({ GraphQL.class, QuerydslDataFetcher.class, ReactiveQuerydslPredicateExecutor.class }) @@ -59,8 +60,8 @@ public class GraphQlReactiveQuerydslAutoConfiguration { List> executors = executorsProvider.stream() .collect(Collectors.toList()); if (!executors.isEmpty()) { - builder.typeVisitors(Collections.singletonList( - QuerydslDataFetcher.autoRegistrationTypeVisitor(Collections.emptyList(), executors))); + builder.configureRuntimeWiring( + QuerydslDataFetcher.autoRegistrationConfigurer(Collections.emptyList(), executors)); } }; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java index 2b8183933a..e3c58bc478 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java @@ -16,6 +16,8 @@ package org.springframework.boot.autoconfigure.graphql; +import java.nio.charset.StandardCharsets; + import graphql.GraphQL; import graphql.execution.instrumentation.ChainedInstrumentation; import graphql.execution.instrumentation.Instrumentation; @@ -30,6 +32,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ClassPathResource; import org.springframework.graphql.GraphQlService; import org.springframework.graphql.data.method.annotation.support.AnnotatedControllerConfigurer; @@ -182,7 +185,9 @@ class GraphQlAutoConfigurationTests { @Bean GraphQlSource customGraphQlSource() { - return mock(GraphQlSource.class); + ByteArrayResource schemaResource = new ByteArrayResource( + "type Query { greeting: String }".getBytes(StandardCharsets.UTF_8)); + return GraphQlSource.builder().schemaResources(schemaResource).build(); } }