|
38 | 38 | import org.springframework.graphql.data.method.annotation.support.AnnotatedControllerConfigurer;
|
39 | 39 | import org.springframework.graphql.execution.BatchLoaderRegistry;
|
40 | 40 | import org.springframework.graphql.execution.DataFetcherExceptionResolver;
|
| 41 | +import org.springframework.graphql.execution.DataLoaderRegistrar; |
41 | 42 | import org.springframework.graphql.execution.GraphQlSource;
|
42 | 43 | import org.springframework.graphql.execution.MissingSchemaException;
|
43 | 44 | import org.springframework.graphql.execution.RuntimeWiringConfigurer;
|
@@ -170,11 +171,18 @@ void shouldDisableFieldIntrospection() {
|
170 | 171 | }
|
171 | 172 |
|
172 | 173 | @Test
|
173 |
| - void shouldConfigCustomBatchLoaderRegistry() { |
174 |
| - this.contextRunner.withUserConfiguration(CustomBatchLoaderRegistryConfiguration.class).run((context) -> { |
175 |
| - assertThat(context).getBeanNames(BatchLoaderRegistry.class).containsOnly("customBatchLoaderRegistry"); |
176 |
| - assertThat(context).hasSingleBean(BatchLoaderRegistry.class); |
177 |
| - }); |
| 174 | + void shouldConfigureCustomBatchLoaderRegistry() { |
| 175 | + this.contextRunner |
| 176 | + .withBean("customBatchLoaderRegistry", BatchLoaderRegistry.class, () -> mock(BatchLoaderRegistry.class)) |
| 177 | + .run((context) -> { |
| 178 | + assertThat(context).hasSingleBean(BatchLoaderRegistry.class); |
| 179 | + assertThat(context.getBean("customBatchLoaderRegistry")) |
| 180 | + .isSameAs(context.getBean(BatchLoaderRegistry.class)); |
| 181 | + assertThat(context.getBean(GraphQlService.class)) |
| 182 | + .extracting("dataLoaderRegistrars", |
| 183 | + InstanceOfAssertFactories.list(DataLoaderRegistrar.class)) |
| 184 | + .containsOnly(context.getBean(BatchLoaderRegistry.class)); |
| 185 | + }); |
178 | 186 | }
|
179 | 187 |
|
180 | 188 | @Configuration(proxyBeanMethods = false)
|
@@ -261,14 +269,4 @@ public void customize(GraphQlSource.Builder builder) {
|
261 | 269 |
|
262 | 270 | }
|
263 | 271 |
|
264 |
| - @Configuration(proxyBeanMethods = false) |
265 |
| - static class CustomBatchLoaderRegistryConfiguration { |
266 |
| - |
267 |
| - @Bean |
268 |
| - BatchLoaderRegistry customBatchLoaderRegistry() { |
269 |
| - return mock(BatchLoaderRegistry.class); |
270 |
| - } |
271 |
| - |
272 |
| - } |
273 |
| - |
274 | 272 | }
|
0 commit comments