diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java index d2348a4d22..8597b6f713 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java @@ -123,9 +123,9 @@ public class GraphQlAutoConfiguration { @Bean @ConditionalOnMissingBean - public GraphQlService graphQlService(GraphQlSource graphQlSource) { + public GraphQlService graphQlService(GraphQlSource graphQlSource, BatchLoaderRegistry batchLoaderRegistry) { ExecutionGraphQlService service = new ExecutionGraphQlService(graphQlSource); - service.addDataLoaderRegistrar(this.batchLoaderRegistry); + service.addDataLoaderRegistrar(batchLoaderRegistry); return service; } 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 e3c58bc478..14656cc3d6 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 @@ -169,6 +169,14 @@ class GraphQlAutoConfigurationTests { }); } + @Test + void shouldConfigCustomBatchLoaderRegistry() { + this.contextRunner.withUserConfiguration(CustomBatchLoaderRegistryConfiguration.class).run((context) -> { + assertThat(context).getBeanNames(BatchLoaderRegistry.class).containsOnly("customBatchLoaderRegistry"); + assertThat(context).hasSingleBean(BatchLoaderRegistry.class); + }); + } + @Configuration(proxyBeanMethods = false) static class CustomGraphQlBuilderConfiguration { @@ -253,4 +261,14 @@ class GraphQlAutoConfigurationTests { } + @Configuration(proxyBeanMethods = false) + static class CustomBatchLoaderRegistryConfiguration { + + @Bean + BatchLoaderRegistry customBatchLoaderRegistry() { + return mock(BatchLoaderRegistry.class); + } + + } + }