17
17
import graphql .schema .GraphQLSchema ;
18
18
import java .util .ArrayList ;
19
19
import java .util .List ;
20
+ import java .util .concurrent .Executor ;
21
+ import java .util .concurrent .Executors ;
20
22
import java .util .function .Supplier ;
21
23
import lombok .Getter ;
22
24
@@ -31,6 +33,7 @@ public class GraphQLConfiguration {
31
33
@ Getter private final long asyncTimeout ;
32
34
private final ContextSetting contextSetting ;
33
35
private final GraphQLResponseCacheManager responseCacheManager ;
36
+ @ Getter private final Executor asyncExecutor ;
34
37
private HttpRequestHandler requestHandler ;
35
38
36
39
private GraphQLConfiguration (
@@ -43,8 +46,10 @@ private GraphQLConfiguration(
43
46
long asyncTimeout ,
44
47
ContextSetting contextSetting ,
45
48
Supplier <BatchInputPreProcessor > batchInputPreProcessor ,
46
- GraphQLResponseCacheManager responseCacheManager ) {
49
+ GraphQLResponseCacheManager responseCacheManager ,
50
+ Executor asyncExecutor ) {
47
51
this .invocationInputFactory = invocationInputFactory ;
52
+ this .asyncExecutor = asyncExecutor ;
48
53
this .graphQLInvoker = graphQLInvoker != null ? graphQLInvoker : queryInvoker .toGraphQLInvoker ();
49
54
this .objectMapper = objectMapper ;
50
55
this .listeners = listeners ;
@@ -137,6 +142,7 @@ public static class Builder {
137
142
private Supplier <BatchInputPreProcessor > batchInputPreProcessorSupplier =
138
143
NoOpBatchInputPreProcessor ::new ;
139
144
private GraphQLResponseCacheManager responseCacheManager ;
145
+ private Executor asyncExecutor = Executors .newCachedThreadPool ();
140
146
141
147
private Builder (GraphQLInvocationInputFactory .Builder invocationInputFactoryBuilder ) {
142
148
this .invocationInputFactoryBuilder = invocationInputFactoryBuilder ;
@@ -192,6 +198,11 @@ public Builder asyncTimeout(long asyncTimeout) {
192
198
return this ;
193
199
}
194
200
201
+ public Builder with (Executor asyncExecutor ) {
202
+ this .asyncExecutor = asyncExecutor ;
203
+ return this ;
204
+ }
205
+
195
206
public Builder with (ContextSetting contextSetting ) {
196
207
if (contextSetting != null ) {
197
208
this .contextSetting = contextSetting ;
@@ -231,7 +242,8 @@ public GraphQLConfiguration build() {
231
242
asyncTimeout ,
232
243
contextSetting ,
233
244
batchInputPreProcessorSupplier ,
234
- responseCacheManager );
245
+ responseCacheManager ,
246
+ asyncExecutor );
235
247
}
236
248
}
237
249
}
0 commit comments