Hey guys, I've started migrating more business logic into pg and so far has been great. I'm now at a point that I need to call an external API (twilio in this case, and email soon) so I'm wondering what the best way is to call an external API when using postgraphql?
I've looked into doing this in postgres but seems like the road is rough. If I need to stay on RDS then a lot of the custom extensions routes are blocked. Even if I decide to use these extensions say a web_fdw, that a network connection could hang the pg process is concerning. Even with background worker since 9.3, I'm not sure if it's wise to go such direction.
So I'm wondering if this is something postgraphql would add, perhaps via a watch that custom JS code could be executed when some values change in the database. Or is there way simpler that I'm missing here? Thanks.
Currently there's two ways I'd recommend:
If you need immediate feedback, then add a REST or alternate endpoint. Sorry.
If you don't need immediate feedback; then you can use triggers/etc to push a row to a queue table, then using NOTIFY/LISTEN along with Pg 9.5's SELECT ... SKIP LOCKED you can implement an extremely responsive parallel queue for a background worker to run.
In future, we plan to add hooks that will allow extending the schema, e.g. https://github.com/postgraphql/postgraphql/issues/300
Adding the experimental hooks discussed in https://github.com/postgraphql/postgraphql/issues/300 should be fairly easy if you want to give it a show. I鈥檒l close for now though, both the REST endpoint and NOTIFY/LISTEN are how I would recommend you add external calls as well while we work on hooks 馃憤