-
Notifications
You must be signed in to change notification settings - Fork 322
Open
Labels
in: dataIssues related to working with dataIssues related to working with datatype: documentationA documentation taskA documentation task
Milestone
Description
In GraphQL it is possible to execute 1.n mutation.
mutation multipleMutations {
m1:createRoute(flightNumber:"LH2722") {
id
}
m2:createRoute(flightNumber:"LH2728") {
id
}
}
If I write the data per mutation via a CrudRepository
, each mutation is transactional on its own. But how can I pack all mutations into a transaction bracket. Is there transaction support via a transactional ExcecutionStrategy
or is there possibly @Transaction
directives support?
mutation @Transaction multipleMutations {
m1:createRoute(flightNumber:"LH2722") {
id
}
m2:createRoute(flightNumber:"LH2728") {
id
}
}
Perhaps the documentation could be expanded to include a Transaction chapter and describe the current options.
Metadata
Metadata
Assignees
Labels
in: dataIssues related to working with dataIssues related to working with datatype: documentationA documentation taskA documentation task
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
jord1e commentedon Jan 30, 2022
This is not implemented because it goes against the specification.
A proposal for something like what you want was launched in December last year:
https://github.com/graphql/graphql-wg/blob/5a09fee3dabd8c7a9313de765ab0370586d13941/notes/2021-12-02.md#discuss-graphql-mutation-designs-with-large-schemas-nested-mutations-30m-aleksandar
graphql/graphql-wg#815
In the meantime you could change your API:
Lists in GraphQL are ordered. So it becomes an application-level concern that the returned ids are ordered.
You could of course create a custom
ExcecutionStrategy
that wraps everything in a Spring transaction, but I am unaware of any other framework doing so. Doing this won't be the recommanded route, as your implementation might defer from the spec at later stages.Thinkenterprise commentedon Feb 2, 2022
@jord1e Thank you for the explanation, the links to the discussions and the workaround.
The topic of mutations and transactions can certainly be discussed in a differentiated manner. And there are some articles about it on the internet.
So I would be grateful if we could include a sentence about it in the Spring GraphQL Documentation?
For example in chapter 5 Data Integration oder chapter 6 Annotated Controllers.
This is just a first suggestion:
After some thought, I also have to say that transaction support at the Spring GraphQL level doesn't make any sense and comes with many questions and problems. I think the transactions need to be resolved via Spring services transactions and repositories transactions depending on the business use case.
[-]Transaction Support for multiple Mutations[/-][+]Explore support for (multiple) transactions and update documentation to provide guidance [/+]