hasura-actions-examples
hasura-actions-examples copied to clipboard
Example of direct interaction with postgres
Show how to create an action that runs a custom SQL query against the db
@macs91 - Hi, can you give me a use case of when you want to run custom SQL and not use the built-in GraphQL APIs? I'm thinking all interactions with the db can be again directly done using the auto-generated APIs.
@praveenweb I'd say complex transactions are mainly the use case. A scenario that involves complex business logic that should be executed as a transaction (I don't have one concrete example right now). You may also need to manually optimize a query.
I think that for the sake of the example a trivial query to the database is enough. It just shows that it's straightforward to do and you're not limited to the autogenerated API.
P.S.: I'm asking this because I know people who think that they are limited by Hasura in the interaction with the db, so these would show these people that direct interaction with the db is straightforward.