hasura-actions-examples icon indicating copy to clipboard operation
hasura-actions-examples copied to clipboard

Example of direct interaction with postgres

Open dhmacs opened this issue 4 years ago • 2 comments

Show how to create an action that runs a custom SQL query against the db

dhmacs avatar Apr 16 '20 17:04 dhmacs

@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 avatar Apr 23 '20 07:04 praveenweb

@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.

dhmacs avatar Apr 23 '20 08:04 dhmacs