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

Enum-valued computed fields #8634

Open
carlpaten opened this issue Jun 27, 2022 · 0 comments
Open

Enum-valued computed fields #8634

carlpaten opened this issue Jun 27, 2022 · 0 comments
Labels
k/enhancement New feature or improve an existing feature

Comments

@carlpaten
Copy link
Contributor

carlpaten commented Jun 27, 2022

Is your proposal related to a problem?

I would like to use computed fields to expose derived data, such as entity status (e.g. how far along is the user in a sign-up flow). With scalar computed fields, I have to use some loose type (usually text or numeric) instead of some kind of table-based enum.

Describe the solution you'd like

Example: given a user table and a user_status enum table, I'd like to be able to define CREATE FUNCTION user_status (user user) RETURNS user_status and use it in a computed column with the correct type.

Describe alternatives you've considered

  • Non-computed column kept up to date with an update trigger at the SQL level: I'd rather not persist derived data. This is also unworkable if the computation is based on values in other tables.
  • Postgres-level generated columns: suffers from the same limitation (can't use data from other tables).
  • Use a custom scalar computed field and override the type in the generated code in codegen.yml: works if you're using graphql-codegen, and might be what we'll go for

If the feature is approved, would you be willing to submit a PR?

I'd need substantial guidance, but yes.

@carlpaten carlpaten added the k/enhancement New feature or improve an existing feature label Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k/enhancement New feature or improve an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants