Skip to main content

SharedWrite

Type Alias SharedWrite 

Source
pub type SharedWrite = Arc<Mutex<Option<Transaction<'static, Postgres>>>>;
Expand description

The transaction every write in one operation shares.

A GraphQL mutation may name several root fields, and the specification resolves them one after another. Hasura runs the whole set in one transaction, so a mutation whose second root field violates a constraint leaves nothing behind from its first – which is what a client sending “create the order and its lines” is relying on. Opening a transaction per resolver, as this used to, half-applies that mutation and reports failure.

Opened lazily by the first write and settled once the operation is answered: committed when the response carries no errors, rolled back otherwise. A query never touches it.

Aliased Type§

pub struct SharedWrite { /* private fields */ }