I am using Hasura on cloud with Postgresql DB.
I have a table called repositories and i would like to achieve this behavior: When the user creates new repository (with my insert_repositories_one mutation) I want to create another repository (insert second row to the table) automaticlly for caching.
I am familiar with Hasura Events but it feels unnecessary to create a new API post request for the event webhook just for creating another repository based on the previos one. Can it be done only with configuration on Hasura? Or should I dive into Postgresql triggers and try to accomplish it there?
Thank you in advance.
There is no automatic way to accomplish this using Hasura alone. You could update your mutation so that both records are created as part of a single transaction.
If you want it to happen "automatically" in response to an insert without needing to have imperative code in your mutation I would recommend that you create a Postgres Trigger instead to take care of the logic. The advantage here is that no matter how the row gets inserted (even if you do it manualy with a SQL query and circumvent the GraphQL API) you will always have a consistent data model