Open tirumaraiselvan opened 4 years ago
It is possible to customise behaviour of mutations using postgres triggers. Also see: https://github.com/hasura/graphql-engine/issues/2940 for a use-case and auditing tables which is built using this mechanism.
In a trigger function, you might want to access hasura session variables as well. This is possible by accessing current_setting function:
current_setting
DECLARE session_variables json; BEGIN session_variables := current_setting('hasura.user', 't'); ... END;
current_setting('hasura.user') will return a json where each key is a session variable.
current_setting('hasura.user')
Be sure to cast the value from current_setting to type json like
session_variables := curent_setting('hasura.user', 't')::json
I forgot this and it drove me nuts.
It is possible to customise behaviour of mutations using postgres triggers. Also see: https://github.com/hasura/graphql-engine/issues/2940 for a use-case and auditing tables which is built using this mechanism.
In a trigger function, you might want to access hasura session variables as well. This is possible by accessing
current_setting
function:current_setting('hasura.user')
will return a json where each key is a session variable.