-
Notifications
You must be signed in to change notification settings - Fork 2.8k
support computed fields returning scalars or set of tables (close #1387) #2917
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
Conversation
|
Deploy preview for hasura-docs ready! Built with commit 2fda8a8 |
|
Review app for commit 28465c8 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
28465c8 to
2ce80d8
Compare
|
Review app for commit 2ce80d8 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
2ce80d8 to
8831cb5
Compare
|
Review app for commit 8831cb5 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
8831cb5 to
7f187e5
Compare
|
Review app for commit 7f187e5 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
|
Review app for commit 32ce5a9 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
32ce5a9 to
465eb82
Compare
|
Review app for commit 465eb82 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
|
Review app for commit 7316063 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
|
Review app for commit 392c26d deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
392c26d to
31bb10d
Compare
|
Review app for commit 31bb10d deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
1f283e0 to
070c551
Compare
|
Review app for commit 070c551 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
|
Review app for commit 6e3646c deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
6e3646c to
0d54b01
Compare
|
Review app for commit 0d54b01 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
|
Review app for commit 84c0a8b deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
1c90172
|
Review app for commit 1c90172 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
|
Just went through the docs and seems like there is a change in the select permissions api. Won't this need changes in the console for adding select permissions for computed fields? edit: realised a whole lot of console changes will be needed. assuming a separate PR will be handling that |
|
Review app for commit c2401a9 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
Resolve Conflicts: server/src-lib/Hasura/GraphQL/Resolve/Types.hs server/tests-py/test_graphql_queries.py
|
Review app for commit 341fc6d deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
|
Review app for commit 2fda8a8 deployed to Heroku: https://hge-ci-pull-2917.herokuapp.com |
|
Review app https://hge-ci-pull-2917.herokuapp.com is deleted |
Description
Computed fields are extra fields added to a table whose value is computed from other columns. It facilitates users to define an additional field to an existing table whose return value is computed via an SQL function.
How it is different from Postgres generated columns
Postgres, from version
12, is introducing Generated Columns.Postgres' generated columns come with its own limitations. Hasura's computed fields are defined via an SQL function, which allows users to define any complex business logic in a function. Generated columns will go together with computed fields where Hasura treats generated columns as normal Postgres columns.
Refer to docs here
Refer to API reference here
Affected components
Related Issues
close #1387
Solution and Design
This PR is a significant change which touches code base for metadata, GraphQL schema generation and resolving and SQL generation.
Metadata
Hasura.RQL.DDL.ComputedFieldadd_computed_fielddrop_computed_fieldrun_sqlquerycreate_select_permissionGraphQL
Eitheris being used before to represent whether a field is a column or a relationship. Now, those types are replaced with proper sum types to represent computed fields too.SQL generation
Modules:-
Hasura.RQL.DML.Select.InternalHasura.RQL.DML.Select.TypesChanges:-
BaseNodenow contains table computed fields as sub-nodes.TableFromchanged toSelectFromGto include a selection from rows returned by a function executionBaseNodeto SQLSelectkeep track of parent node prefix to execute the computed field function with the parent table row identifier.In module
Hasura.SQL.DMLaddFunctionExptoSQLExpAST.The following function is added to the
authortable as a computed field with namecomputed_articlesQuerying data from author table along with computed field
computed_articlesGenerates the SQL below.
Steps to test and verify
Follow any test case or example
Limitations, known bugs & workarounds
whereclause (bool exps)