Starting a database transaction in a mutation contesxt #3380
-
Hello all, I am trying to ensure all mutations run inside a single database transaction. I realyzed I need these things:
I am using the FastAPI integration to leverage dependency injection, but I don't have a way to run some code before the query is executed and then another code chunk after the query execution ends, successfully or not. The motivation for this is that I am developing a mutation system that adds modifying resolvers inside resolved mutation results got from root. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, did you already take a look at the Strawberry extensions system? You could possibly make use of the |
Beta Was this translation helpful? Give feedback.
Hi, did you already take a look at the Strawberry extensions system?
You could possibly make use of the
on_operation
oron_execute
lifecycle hooks to run code before and after execution of your resolvers. Viaself.execution_context
you should be able to figure out whether your operation is a query, mutation or subscription.