Feature request: using functions with session arguments to define computed columns
See original GitHub issueThis is closely related to #2760 with the same motivation, except that I would like to have a view which transforms (not filters!) a table based on X-Hasura-User-Id
. A straightforward solution is to expose session variables in queries under current_setting('hasura.user')
similarly to how it’s done in mutations. In fact, the change implementing this is simple:
--- a/server/src-lib/Hasura/GraphQL/Transport/HTTP.hs
+++ b/server/src-lib/Hasura/GraphQL/Transport/HTTP.hs
@@ -50,7 +50,7 @@ runHasuraGQ reqId query userInfo resolvedOp = do
E.ExOpQuery tx genSql -> do
-- log the generated SQL and the graphql query
liftIO $ logGraphqlQuery logger $ QueryLog query genSql reqId
- runLazyTx' pgExecCtx tx
+ runLazyTx pgExecCtx $ withUserInfo userInfo tx
E.ExOpMutation tx -> do
-- log the graphql query
liftIO $ logGraphqlQuery logger $ QueryLog query Nothing reqId
Still, I wanted to make sure the idea itself is sound before opening a PR.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:8 (5 by maintainers)
Top Results From Across the Web
accessing session variables in function via computed field
and use it via a computed field without any args. I know that in order to get hasura_session injected the function needs to...
Read more >Postgres: Computed fields | Hasura GraphQL Docs
Computed fields are virtual values or objects that are dynamically computed and can be queried along with a table/view's columns. Computed fields are...
Read more >Computed Columns | CockroachDB Docs
A computed column exposes data generated by an expression included in the column definition.
Read more >ALTER TABLE computed_column_definition (Transact-SQL)
ALTER TABLE computed_column_definition specifies the properties of a computed column that is added to a table by using ALTER TABLE.
Read more >Is there a way to prevent Scalar UDFs in computed columns ...
Yes if you: are running SQL Server 2014 or later; and; are able to run the query with trace flag 176 active; and;...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, this is high up in our priority list. Actually, it was being tracked here: https://github.com/hasura/graphql-engine/issues/3846
I am closing this issue in favour of #3846 (as more eyeballs there)
@lexi-lambda No. #3143 only support root SQL function queries to access session information. This needs to be done.