-
Notifications
You must be signed in to change notification settings - Fork 324
feat: added option to use a transactional query invoker #299
feat: added option to use a transactional query invoker #299
Conversation
@@ -23,6 +23,8 @@ dependencies { | |||
|
|||
compile "org.springframework.boot:spring-boot-autoconfigure:$LIB_SPRING_BOOT_VER" | |||
compile "org.springframework.boot:spring-boot-starter-websocket:$LIB_SPRING_BOOT_VER" | |||
compile "javax.transaction:javax.transaction-api:$LIB_TRANSACTIONS_API_VERSION" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these be included as compileOnly
instead so we're not pulling in more dependencies? People that want to use this will probably have these dependencies themselves anyway already, won't they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, made them compileOnly
. transaction-api
is also included as testCompile
, as it is currently used in one of the tests.
This may prevent LazyInitializationException when working with JPA entities across multiple resolvers (thus making individual resolvers Transactional is not sufficient). By default, this feature is disabled. It can be enabled in application.properties/yaml with: graphql.query-invoker.transactional=true
01ba914
to
fc611f8
Compare
@BlasiusSecundus |
@oliemansm could you provide an example? Also, graphql.query-invoker.transactional=true is described in readme, while not merged/released, causing my confusion why it is not working :) |
Updated the readme, thanks for pointing it out. If the default settings are good for you, and you only want to use a custom @Bean
public GraphQLQueryInvoker queryInvoker(ExecutionStrategyProvider executionStrategyProvider) {
GraphQLQueryInvoker.Builder builder = GraphQLQueryInvoker.newBuilder()
.withExecutionStrategyProvider(executionStrategyProvider);
return new MyCustomQueryInvoker(builder.build());
} |
@oliemansm, thanks for the update and the explanation.
That makes a good point. (The PR originated from one such a separate need/solution for that need) |
Using the transactional query invoker prevents
LazyInitializationException
occurring when working with JPA entities across multiple resolvers (thus making individual resolvers Transactional is not sufficient).By default, this feature is disabled. It can be enabled in
application.properties/yaml
with:graphql.query-invoker.transactional=true