Han
1 min readApr 3, 2022

--

Great question. In fact, we use PostGraphile quite a lot. But we only use it to generate the "Query" fields, not the "mutation" field. Usually apps get more complex for "mutation" first, and we write most of "data writing" logic with Domain driven designs and expost our own mutations. There is also the idea of avoiding "anemic mutations"(see https://xuorig.medium.com/graphql-mutation-design-anemic-mutations-dd107ba70496), which is probably why Postgraphile offers a `disableDefaultMutation` option. The point is, PostGraphile's way of custom mutation is to write a pg_function for postgraphile to auto expose it as mutation, but it is pretty hard to maintain once you have a couple dozen of those. This might be ok if you are just running a blog or some sort, but the difficulty is quite noticable if you are writing an complex content manager, like backend admin panel for a company. So in summary, if you need to do custom mutations, do it in a "data source", "core js" place, not in pg_functions. This is an very strong opinionated respond, I wouldn't want you to just listen to me, you should critially think about it and come up with decision yourself :).

--

--

Han
Han

Written by Han

Google SWE | Newly Dad | Computational Biology PhD | Home Automation Enthusiast

Responses (1)