Add support for PostgreSQL procedures (CALL-based mutations) - #3124
Add support for PostgreSQL procedures (CALL-based mutations)#3124dargmuesli wants to merge 8 commits into
Conversation
🦋 Changeset detectedLatest commit: c4d1b55 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
0a9838e to
c4d1b55
Compare
I think this might be the case for regular functions too, if so we have handling for it already. I might be wrong though. |
|
Only glancing at this because I'm in the middle of some other work, so forgive brevity. Seems |
|
Thanks for the quick feedback! I evaluated using PROCEDUREs in my app a bit more and came to the conclusion that they are of little use for me and I think most other postgraphile projects will come to a similar conclusion. Let me know if you think supporting PROCEDUREs is even in scope for postgraphile. Not saying it shouldn't be but it's definitely an edge case / advanced feature. If you think supporting it makes sense, I'll take care of your feedback above! |
|
I'm somewhat indifferent to it until someone has a really pressing and convincing need for it. Functions are pretty powerful and the integrate well and efficiently into the system 🤷♂️ |
Summary
Resolves #1309.
Adds support for PostgreSQL
PROCEDUREs (introduced in PG11). Previously a procedure either didn't appear in the schema or got built into a GraphQL field that crashed at query time, since Postgres procedures can only be invoked withcall proc(...), never embedded in aselectlike a function.@dataplan/pg: newPgCallStep/pgCall()step that builds and executes acallstatement directly, including the positional-argument handling procedures require (every parameter, including OUT-only ones, needs a value) and raw-text decoding for the output columns (which can't be wrapped in::textcasts the way a select list can).graphile-build-pg:PgProceduresPlugindetectsprokind = 'p'and builds a CALL-backed resource; procedures are always mutation fields, since they can never appear in a query, computed column, or connection.PgCustomTypeFieldPlugin'sclientMutationIdwiring is extended to recognizePgCallStepresults alongsidePgSelectStepones.proceduresschema (PG11+) covering no-output, single-output, multiple-output, andINOUTprocedures, plus a mutation test exercising each includingclientMutationId.procedures.mdnow documents the feature and its limitations instead of saying it's unsupported.Known limitation: a single-output procedure's result is a nested object (
{ result { doubled } }) rather than flattened to a bare scalar the way single-output functions are, since Postgres reportsrecordas a procedure's return type even with just one OUT parameter.