Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for UDFs as GraphQL queries/mutations #393

Merged
merged 102 commits into from
Sep 26, 2023
Merged

Conversation

imor
Copy link
Contributor

@imor imor commented Jul 24, 2023

What kind of change does this PR introduce?

New feature and docs update.

What is the current behavior?

User defined functions are not available through GraphQL.

What is the new behavior?

User defined functions are available as fields on the query and mutation root types.

Additional context

Tasks

Add support for base types:

  • Add UDF metadata to sql context.
  • Expose UDFs in introspection schema.
  • Parse UDF fields on mutation and query objects.
  • Transpile & execute UDF field requests.
  • Add tests

Add support for composite types:

  • Add UDF metadata to sql context.
  • Expose UDFs in introspection schema.
  • Parse UDF fields on mutation and query objects.
  • Transpile & execute UDF field requests.
  • Add tests

Misc:

  • Remove tables->functions key and use the new functions in sql context for columns extended with functions.
  • Handle function name clashes with other fields. E.g. if there is a table named account and a function named accountCollection.
  • Accept args for function which return a single table row.
  • Add support for argument name inflection.
  • Update docs.

Resolves #222

@imor
Copy link
Contributor Author

imor commented Sep 6, 2023

this looks really great. the asks would be:

  • Add in the return type transforms so e.g. bigint gets returned as as string and json as an escaped json string
  • Filter out the functions that aren't supported yet rather than leaving their behavior as undefined

+1 on your API design decisions

In case you hadn't seen these, good reading: https://www.graphile.org/postgraphile/functions/ https://www.graphile.org/postgraphile/custom-mutations/

Yeah, I have read these. Actually these pages influenced a lot of the design choices for our implementation.

@imor imor requested a review from olirice September 7, 2023 02:41
src/transpile.rs Outdated Show resolved Hide resolved
test/sql/function_calls.sql Outdated Show resolved Hide resolved
test/expected/function_calls.out Outdated Show resolved Hide resolved
If a function returning Node returned null, it output a row with every
field as null rather than a null top level object.
@imor imor requested a review from olirice September 14, 2023 10:56
@imor imor requested a review from olirice September 26, 2023 06:20
@olirice olirice merged commit e81046c into supabase:master Sep 26, 2023
4 checks passed
@imor imor deleted the expose_udfs branch September 27, 2023 06:22
@imor imor mentioned this pull request Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Expose Stored Procedures as GraphQL Mutations
3 participants