accesing hasura session from custom function fails
See original GitHub issueI tried to follow the steps to create a custom function and access the hasura session variables from here and there are 2 issues
1- if you track the function from the console, when you execute the query it complains about not having the arguments variable
2- in order to get the session variables, I tracked the function through the API and then I get this error
{
"errors": [
{
"extensions": {
"internal": {
"statement": "WITH \"public_get_session_role__result\" AS (SELECT * FROM \"public\".\"get_session_role\"() ) SELECT coalesce(json_agg(\"root\" ), '[]' ) AS \"root\" FROM (SELECT row_to_json((SELECT \"_1_e\" FROM (SELECT \"_0_root.base\".\"result\" AS \"result\" ) AS \"_1_e\" ) ) AS \"root\" FROM (SELECT * FROM \"public_get_session_role__result\" WHERE ('true') ) AS \"_0_root.base\" ) AS \"_2_root\" ",
"prepared": true,
"error": {
"exec_status": "FatalError",
"hint": "No function matches the given name and argument types. You might need to add explicit type casts.",
"message": "function public.get_session_role() does not exist",
"status_code": "42883",
"description": null
},
"arguments": [
"(Oid 114,Just (\"{\\\"x-hasura-role\\\":\\\"admin\\\",\\\"x-hasura-user-id\\\":\\\"15169bf8-294a-49cb-9d48-13a39a8c016e\\\"}\",Binary))"
]
},
"path": "$",
"code": "unexpected"
},
"message": "postgres query error"
}
]
}
I’m using hasura v1.0.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Developers - accesing hasura session from custom function fails -
I tried to follow the steps to create a custom function and access the hasura session variables from here and there are 2...
Read more >Handling GraphQL Errors with Hasura & React
A guide to common GraphQL API & Hasura specific errors and how to handle them with React pages.
Read more >Postgres: Extend schema with SQL functions - Hasura
Accessing Hasura session variables in custom functions. Create a function with an argument for session variables and track it with the pg_track_function ...
Read more >Action handlers | Hasura GraphQL Docs
Actions need to be backed by custom business logic. ... Hasura makes a POST request to the handler with the action arguments and...
Read more >Functions: Accessing Session Variables | Data Models & Auth
Create a function with an argument for session variables and track it using your Hasura API. This example will look at creating a...
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
I was able to reproduce here too.
@tafelito fyi looking at the PR I realized a quick fix for the meantime. Just add a second argument to your function and to your queries.
@rakeshkky, getting information about the user currently logged in seems common enough that you might want to add this specific use-case to Hasura’s documentation.
@rakeshkky, also, would love to have the v2 of the
track_function
function available through the console/GUI—although this is probably already on your radar.Thanks a bunch.
Yes the function was tracked via console. Here’s my schema and function definition I’m currently using:
users table:
Let me know if you need anything else.