Reuse BatchLoaderRegistry in GraphQlService

See gh-29929
pull/29976/head
dugenkui03 3 years ago committed by Stephane Nicoll
parent 8ee9681d36
commit 043e5ff0f5

@ -123,9 +123,9 @@ public class GraphQlAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public GraphQlService graphQlService(GraphQlSource graphQlSource) { public GraphQlService graphQlService(GraphQlSource graphQlSource, BatchLoaderRegistry batchLoaderRegistry) {
ExecutionGraphQlService service = new ExecutionGraphQlService(graphQlSource); ExecutionGraphQlService service = new ExecutionGraphQlService(graphQlSource);
service.addDataLoaderRegistrar(this.batchLoaderRegistry); service.addDataLoaderRegistrar(batchLoaderRegistry);
return service; return service;
} }

@ -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) @Configuration(proxyBeanMethods = false)
static class CustomGraphQlBuilderConfiguration { static class CustomGraphQlBuilderConfiguration {
@ -253,4 +261,14 @@ class GraphQlAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomBatchLoaderRegistryConfiguration {
@Bean
BatchLoaderRegistry customBatchLoaderRegistry() {
return mock(BatchLoaderRegistry.class);
}
}
} }

Loading…
Cancel
Save