43
43
import graphql .kickstart .execution .config .ObjectMapperProvider ;
44
44
import graphql .kickstart .execution .error .GraphQLErrorHandler ;
45
45
import graphql .kickstart .servlet .AbstractGraphQLHttpServlet ;
46
+ import graphql .kickstart .servlet .AsyncTaskDecorator ;
46
47
import graphql .kickstart .servlet .GraphQLConfiguration ;
47
48
import graphql .kickstart .servlet .GraphQLHttpServlet ;
48
49
import graphql .kickstart .servlet .cache .GraphQLResponseCacheManager ;
61
62
import java .util .List ;
62
63
import java .util .Map ;
63
64
import java .util .Map .Entry ;
65
+ import java .util .concurrent .Executor ;
64
66
import javax .servlet .MultipartConfigElement ;
65
67
import lombok .RequiredArgsConstructor ;
66
68
import lombok .extern .slf4j .Slf4j ;
101
103
havingValue = "true" ,
102
104
matchIfMissing = true )
103
105
@ AutoConfigureAfter ({GraphQLJavaToolsAutoConfiguration .class , JacksonAutoConfiguration .class })
104
- @ EnableConfigurationProperties ({GraphQLServletProperties .class })
106
+ @ EnableConfigurationProperties ({GraphQLServletProperties .class , AsyncServletProperties . class })
105
107
public class GraphQLWebAutoConfiguration {
106
108
107
109
public static final String QUERY_EXECUTION_STRATEGY = "queryExecutionStrategy" ;
108
110
public static final String MUTATION_EXECUTION_STRATEGY = "mutationExecutionStrategy" ;
109
111
public static final String SUBSCRIPTION_EXECUTION_STRATEGY = "subscriptionExecutionStrategy" ;
110
112
111
113
private final GraphQLServletProperties graphQLServletProperties ;
114
+ private final AsyncServletProperties asyncServletProperties ;
112
115
private final ErrorHandlerSupplier errorHandlerSupplier = new ErrorHandlerSupplier (null );
113
116
114
117
@ Bean
@@ -293,7 +296,9 @@ public GraphQLConfiguration graphQLServletConfiguration(
293
296
GraphQLObjectMapper graphQLObjectMapper ,
294
297
@ Autowired (required = false ) List <GraphQLServletListener > listeners ,
295
298
@ Autowired (required = false ) BatchInputPreProcessor batchInputPreProcessor ,
296
- @ Autowired (required = false ) GraphQLResponseCacheManager responseCacheManager ) {
299
+ @ Autowired (required = false ) GraphQLResponseCacheManager responseCacheManager ,
300
+ @ Autowired (required = false ) AsyncTaskDecorator asyncTaskDecorator ,
301
+ @ Autowired (required = false ) Executor asyncExecutor ) {
297
302
return GraphQLConfiguration .with (invocationInputFactory )
298
303
.with (graphQLInvoker )
299
304
.with (graphQLObjectMapper )
@@ -303,6 +308,10 @@ public GraphQLConfiguration graphQLServletConfiguration(
303
308
.with (graphQLServletProperties .getContextSetting ())
304
309
.with (responseCacheManager )
305
310
.asyncTimeout (graphQLServletProperties .getAsyncTimeout ())
311
+ .with (asyncTaskDecorator )
312
+ .asyncCorePoolSize (asyncServletProperties .getThreads ().getMin ())
313
+ .asyncCorePoolSize (asyncServletProperties .getThreads ().getMax ())
314
+ .with (asyncExecutor )
306
315
.build ();
307
316
}
308
317
0 commit comments