Skip to content

Commit 0bb8f58

Browse files
committed
BatchLoaderRegistry extends DataLoaderRegistrar
Given that BatchLoaderRegistry is declared as a bean and injected into ExecutionGraphQlService as a DataLoaderRegistrar, it makes sense to have be a DataLoaderRegistrar vs declaring the bean as the implementation type. A BatchLoaderRegistry is supposed to result in DataLoader registrations so this makes sense in any case.
1 parent 56ca50e commit 0bb8f58

File tree

10 files changed

+15
-14
lines changed

10 files changed

+15
-14
lines changed

graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlServiceAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
@AutoConfigureAfter(GraphQlAutoConfiguration.class)
4444
public class GraphQlServiceAutoConfiguration {
4545

46-
private final DefaultBatchLoaderRegistry batchLoaderRegistry = new DefaultBatchLoaderRegistry();
46+
private final BatchLoaderRegistry batchLoaderRegistry = new DefaultBatchLoaderRegistry();
4747

4848
@Bean
4949
public BatchLoaderRegistry batchLoaderRegistry() {

spring-graphql/src/main/java/org/springframework/graphql/execution/BatchLoaderRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import reactor.core.publisher.Mono;
2828

2929
/**
30-
* Registry of functions that batch load data values given a set of keys.
30+
* Registry for functions to batch load data values, given a set of keys.
3131
*
3232
* <p>At request time, each function is registered as a
3333
* {@link org.dataloader.DataLoader} in the {@link org.dataloader.DataLoaderRegistry}
@@ -41,7 +41,7 @@
4141
* @see org.dataloader.MappedBatchLoader
4242
* @see org.dataloader.DataLoader
4343
*/
44-
public interface BatchLoaderRegistry {
44+
public interface BatchLoaderRegistry extends DataLoaderRegistrar {
4545

4646
/**
4747
* Begin the registration of a new batch load function by specifying the

spring-graphql/src/main/java/org/springframework/graphql/execution/DataLoaderRegistrar.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
import org.dataloader.DataLoaderRegistry;
1919

2020
/**
21-
* Contract for access to the {@link DataLoaderRegistry} at request time.
21+
* Contract for callback access to the {@link DataLoaderRegistry} as it is
22+
* initialized for each request.
2223
*
2324
* @author Rossen Stoyanchev
2425
* @since 1.0.0

spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultBatchLoaderRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* @author Rossen Stoyanchev
4646
* @since 1.0.0
4747
*/
48-
public class DefaultBatchLoaderRegistry implements BatchLoaderRegistry, DataLoaderRegistrar {
48+
public class DefaultBatchLoaderRegistry implements BatchLoaderRegistry {
4949

5050
private final List<ReactorBatchLoader<?,?>> loaders = new ArrayList<>();
5151

spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/BatchMappingDetectionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
@SuppressWarnings({"rawtypes", "unused"})
4848
public class BatchMappingDetectionTests {
4949

50-
private final DefaultBatchLoaderRegistry batchLoaderRegistry = new DefaultBatchLoaderRegistry();
50+
private final BatchLoaderRegistry batchLoaderRegistry = new DefaultBatchLoaderRegistry();
5151

5252

5353
@Test

spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/BatchMappingInvocationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.springframework.graphql.RequestInput;
4040
import org.springframework.graphql.data.method.annotation.BatchMapping;
4141
import org.springframework.graphql.data.method.annotation.QueryMapping;
42-
import org.springframework.graphql.execution.DataLoaderRegistrar;
42+
import org.springframework.graphql.execution.BatchLoaderRegistry;
4343
import org.springframework.graphql.execution.DefaultBatchLoaderRegistry;
4444
import org.springframework.graphql.execution.ExecutionGraphQlService;
4545
import org.springframework.graphql.execution.GraphQlSource;
@@ -268,9 +268,9 @@ public GraphQlSource graphQlSource(AnnotatedDataFetcherConfigurer configurer) {
268268
}
269269

270270
@Bean
271-
public GraphQlService graphQlService(GraphQlSource source, DataLoaderRegistrar registrar) {
271+
public GraphQlService graphQlService(GraphQlSource source, BatchLoaderRegistry registry) {
272272
ExecutionGraphQlService service = new ExecutionGraphQlService(source);
273-
service.addDataLoaderRegistrar(registrar);
273+
service.addDataLoaderRegistrar(registry);
274274
return service;
275275
}
276276

@@ -280,7 +280,7 @@ public AnnotatedDataFetcherConfigurer annotatedDataFetcherConfigurer() {
280280
}
281281

282282
@Bean
283-
public DefaultBatchLoaderRegistry batchLoaderRegistry() {
283+
public BatchLoaderRegistry batchLoaderRegistry() {
284284
return new DefaultBatchLoaderRegistry();
285285
}
286286
}

spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/DataLoaderArgumentResolverTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void resolveArgumentFailureNoMatch() {
113113
}
114114

115115
private DataFetchingEnvironment initEnvironment(Consumer<BatchLoaderRegistry> registryConsumer) {
116-
DefaultBatchLoaderRegistry batchLoaderRegistry = new DefaultBatchLoaderRegistry();
116+
BatchLoaderRegistry batchLoaderRegistry = new DefaultBatchLoaderRegistry();
117117
registryConsumer.accept(batchLoaderRegistry);
118118

119119
DataLoaderRegistry registry = DataLoaderRegistry.newRegistry().build();

spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/SchemaMappingInvocationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public AnnotatedDataFetcherConfigurer annotatedDataFetcherConfigurer() {
245245
}
246246

247247
@Bean
248-
public DefaultBatchLoaderRegistry batchLoaderRegistry() {
248+
public BatchLoaderRegistry batchLoaderRegistry() {
249249
return new DefaultBatchLoaderRegistry();
250250
}
251251

spring-graphql/src/test/java/org/springframework/graphql/execution/BatchLoadingTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void batchLoader() {
5757
}));
5858
});
5959

60-
DefaultBatchLoaderRegistry registry = new DefaultBatchLoaderRegistry();
60+
BatchLoaderRegistry registry = new DefaultBatchLoaderRegistry();
6161
registry.forTypePair(Long.class, Author.class)
6262
.registerBatchLoader((ids, env) -> Flux.fromIterable(ids).map(BookSource::getAuthor));
6363

spring-graphql/src/test/java/org/springframework/graphql/execution/DefaultBatchLoaderRegistryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
public class DefaultBatchLoaderRegistryTests {
3636

37-
private final DefaultBatchLoaderRegistry batchLoaderRegistry = new DefaultBatchLoaderRegistry();
37+
private final BatchLoaderRegistry batchLoaderRegistry = new DefaultBatchLoaderRegistry();
3838

3939
private final DataLoaderRegistry dataLoaderRegistry = DataLoaderRegistry.newRegistry().build();
4040

0 commit comments

Comments
 (0)