API
Transactional Operations
Requests to the GraphQL API are executed in a single transaction context with all-or-nothing semantics.
Requests may contain multiple query or mutation operations. Every operation within a single request is executed within the same database transaction context, meaning that each operation will only succeed if all operations succeed.
In other words, if there is an error in any single operation, none of the operations will succeed. Transactional database operations are useful because they help maintain data integrity, consistency, and reliability in applications that require complex operations or involve multiple data manipulation steps.
For example, the following request includes two postTransaction
mutations, but the second uses incorrect syntax that triggers a JSON_PARSE_ERROR
.
Example
mutation PostTXs {
tx_1: postTransaction(
input: {
transactionId: "5c328550-bba3-423b-a58a-b3f9786a80ad"
tranCode: "ACH_CREDIT"
params: {
account: "260fd651-8819-4f99-9c8a-87d27e03ee4c"
amount: "10.25"
effective: "2022-09-08"
}
}
) {
transactionId
}
tx_2: postTransaction(
input: {
transactionId: "cd48f439-1f7b-40aa-9b95-4fcbbb51e3cf"
tranCode: "ACH_CREDIT"
params: {
account: "ae9d36cb-dcf5-41a9-bc1e-99a1cf56ef5b"
amount: "31.72"
effective: "2022-09-09"
}
}
) {
transactionId
}
}
Note that the "data"
field in the response is null
because neither transaction was posted. If we were to subsequently query for the first (valid) transaction, we would see that it was not posted.