Skip to main content

Transaction Decorator

Runs the decorated method in a TypeORM transaction. It works by creating a transactional QueryRunner which gets attached to the RequestContext object. When the RequestContext is the passed to the TransactionalConnection getRepository() method, this QueryRunner is used to execute the queries within this transaction.

Essentially, the entire resolver function is wrapped in a try-catch block which commits the transaction on successful completion of the method, or rolls back the transaction in an unhandled error is thrown.

Example

Ts

The Transaction decorator can handle transactions automatically (which is the default) or be set to "manual" mode, where the TransactionalConnection .startTransaction() and .commitOpenTransaction() methods must them be used.

Example

Ts

Note that even in manual mode, a rollback will be automatically performed in the case that an uncaught error is thrown within the resolver.

Signature

Transactions can be run at different isolation levels. The default is undefined, which falls back to the default of your database. See the documentation of your database for more information on available isolation levels.

Signature
Was this chapter helpful?
Report Issue
Edited Feb 25, 2026ยทEdit this page