|
|
|
|
|
by agentultra
3082 days ago
|
|
You can manage that with mutations which correspond with PostgreSQL functions to do the writing in the Postgraphile system. create or replace function addFrobnoz (fooId uuid, frobnoz uuid)
returns void as $$
declare
foo row;
begin
-- fetch and validate foo wrt. frobnoz
select insertIntoEventStore(
"frobnozAdded",
json_build_object('frobnoz', frobnoz));
end;
$$ language plpgsql;
Where `insertIntoEventStore` does what it says, maintains a monotonic sequence, etc, etc. Postgraphile can discover the _command_ functions as mutations and map them the GraphQL mutations spec for you. Then your projections just fill in the read tables for you and that's what Postgraphile will read from.And if you need side-effects like sending email or stream more complicated aggregates there are lots of options in PostgreSQL to use the `notify/subscribe` system or use extensions to publish off to a message queue directly. |
|