feat(graphile-function-bindings): expose API-bound functions as GraphQL mutations#1365
Closed
pyramation wants to merge 2 commits into
Closed
feat(graphile-function-bindings): expose API-bound functions as GraphQL mutations#1365pyramation wants to merge 2 commits into
pyramation wants to merge 2 commits into
Conversation
…QL mutations One mutation per graphql-enabled function_api_bindings row for the API, with input types derived from JSON Schema / payload_args (JSON fallback) and a plain RLS-enforced insert into function_invocations. Track B2 of constructive-io/constructive-planning#1149
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Track B2 of constructive-io/constructive-planning#1149.
New
graphile/graphile-function-bindingspackage: a PostGraphile v5 plugin that, at gather time, loadsfunction_api_bindings ⋈ function_definitionsfor the configuredapiIdand emits one mutation per graphql-enabled binding:configjsonb: absentgraphqlkey ⇒ enabled;"graphql": false⇒ not exposed.src/derive.ts, shared source for future REST validation, no runtime validation):config.schema/config.payloadSchema→ typed input object (string/number/boolean/enum/array,required⇒ non-null)payload_args([{name, type}]) → nullable scalar fieldsinput { payload: JSON }passed through verbatimINSERT INTO <schema>.function_invocations (database_id, task_identifier, payload)via the Grafast context'swithPgClient/pgSettings— RLS-enforced on the normal authenticated connection; the plugin never setsjwt.claims.*(server layer suppliesjwt.claims.api_idprovenance).invocationfield reuses the generatedFunctionInvocationtype viapgRegistryresource lookup (resource.get({ id })) when the table is exposed.graphql/server/src/middleware/graphile.tsbuildPreset(..., apiId)addscreateFunctionBindingsPlugin({ apiId })per API handler.Tests (graphile-test + seeded
fn_testschema): mutation-per-binding schema snapshot, disabled/other-api bindings omitted, payload_args + JSON Schema input introspection, JSON fallback, and resolver insert returning the created invocation.pnpm test22/22, package + server builds green.Link to Devin session: https://app.devin.ai/sessions/0aa9b0eb80e24f57abbe55773acaa4f5
Requested by: @pyramation