crystal icon indicating copy to clipboard operation
crystal copied to clipboard

PostGraphile docs: ambiguous example in makeExtendSchemaPlugin docs

Open jemgillam opened this issue 1 year ago • 1 comments

Summary

https://postgraphile.org/postgraphile/next/make-extend-schema-plugin#example-2 needs fixing, add some warnings around it for context

Additional context

One of our sponsors has asked if there's a potential N+1 problem within this example, which Benjie has described as "terrible".

withPgClient by default is designed for use in mutations. It runs the query once for each entry in the batch. At the root level (as here) there is no N (we're at root) so this is fine; but if you were to add that to a non-root type (e.g. User or Post or whatever) then yes absolutely it would destroy performance. Further withPgClient is flagged as a mutation (hasSideEffects = true) and that will impact the efficiency of your plans too.

jemgillam avatar May 03 '24 10:05 jemgillam

Related: #2044

jemgillam avatar Jun 11 '25 13:06 jemgillam