3
3
import static com .introproventures .graphql .jpa .query .schema .impl .BatchLoaderRegistry .getMappedBatchDataLoaderMap ;
4
4
5
5
import graphql .GraphQL ;
6
+ import java .util .Map ;
7
+ import java .util .concurrent .CompletableFuture ;
6
8
import org .dataloader .DataLoaderOptions ;
7
9
import org .springframework .beans .factory .InitializingBean ;
8
10
import org .springframework .beans .factory .ListableBeanFactory ;
14
16
import org .springframework .context .annotation .Bean ;
15
17
import org .springframework .graphql .ExecutionGraphQlService ;
16
18
import org .springframework .graphql .execution .BatchLoaderRegistry ;
17
- import org .springframework .graphql .execution .DefaultExecutionGraphQlService ;
18
19
import org .springframework .graphql .execution .GraphQlSource ;
19
20
import reactor .core .publisher .Mono ;
20
21
@@ -25,7 +26,18 @@ public class GraphQLJpaQueryGraphQlExecutionAutoConfiguration {
25
26
@ Bean
26
27
@ ConditionalOnMissingBean
27
28
BatchLoaderRegistry batchLoaderRegistry (ListableBeanFactory beanFactory ) {
28
- return new GraphQlAutoConfiguration (beanFactory ).batchLoaderRegistry ();
29
+ var batchLoaderRegistry = new GraphQlAutoConfiguration (beanFactory ).batchLoaderRegistry ();
30
+
31
+ DataLoaderOptions options = DataLoaderOptions .newOptions ().setCachingEnabled (false );
32
+
33
+ batchLoaderRegistry
34
+ .forName (GraphQLJpaQueryGraphQlExecutionAutoConfiguration .class .getName ())
35
+ .withOptions (options )
36
+ .registerMappedBatchLoader ((keys , env ) ->
37
+ Mono .fromCompletionStage (CompletableFuture .completedStage (Map .of ()))
38
+ );
39
+
40
+ return batchLoaderRegistry ;
29
41
}
30
42
31
43
@ Bean
@@ -40,10 +52,7 @@ ExecutionGraphQlService executionGraphQlService(
40
52
}
41
53
42
54
@ Bean
43
- InitializingBean batchLoaderRegistryConfigurer (
44
- DefaultExecutionGraphQlService executionGraphQlService ,
45
- BatchLoaderRegistry batchLoaderRegistry
46
- ) {
55
+ InitializingBean batchLoaderRegistryConfigurer (BatchLoaderRegistry batchLoaderRegistry ) {
47
56
return () -> {
48
57
DataLoaderOptions options = DataLoaderOptions .newOptions ().setCachingEnabled (false );
49
58
@@ -56,8 +65,6 @@ InitializingBean batchLoaderRegistryConfigurer(
56
65
Mono .fromCompletionStage (mappedBatchLoader .load (keys , env ))
57
66
)
58
67
);
59
-
60
- executionGraphQlService .addDataLoaderRegistrar (batchLoaderRegistry );
61
68
};
62
69
}
63
70
}
0 commit comments