Open petr-ujezdsky opened 4 years ago
I'd say your current solution is more a workaround and a better mechanism should be provided.
For me it worked to define an ExecutionStrategyProvider
instead of defining the Map
.
@Bean
public ExecutionStrategyProvider executionStrategyProvider(
AsyncTransactionalExecutionStrategy queryExecutionStrategy) {
return new DefaultExecutionStrategyProvider(queryExecutionStrategy, null, null);
}
TL;DR
is populated by spring as map
beanName -> bean
, when I have someExecutionStrategy
in spring context.Problem
I was trying to inject my custom
executionStrategies
bean forExecutionStrategyProvider
creation insideGraphQLWebAutoConfiguration
.In my own
@Configuration
annotated class I have created simple beanWhere
AsyncTransactionalExecutionStrategy
is another bean (with transaction over whole graphql execution to enable lazy hibernate calls)The problem is, that the
executionStrategyProvider(...)
insideGraphQLWebAutoConfiguration
is called before my configuration and my map bean creation.executionStrategies
is injected with mapbeanName -> bean
(of 1 instance) instead of map from my bean that usesGraphQLWebAutoConfiguration.QUERY_EXECUTION_STRATEGY
and alike as keys. TheexecutionStrategyProvider
then works unexpectedly - it uses the one strategy for query, mutation and subscription.Solution (kind of)
The solution is to name my bean using the expected keys
and do not use the
executionStrategies(...)
bean inside my config. This populates theexecutionStrategies
map with proper keys (beanName = expected key). But is this the "right" way that is intended?