Setting an arbitrary GUC via server config / env variables? #8523
-
I know there are various command flags or environment variables for configuring the Hasura server itself, but is there any way to set arbitrary GUC variables that have nothing to do with Hasura? My use case here is another service I run on top of the same Postgres database that expects and uses certain GUC values, and I'd like to be able to call some of the same functions but they will fail if said GUCs are not defined. The values for these would be available on startup of the Hasura (and other) services, but not for every incoming request, hence why I'd want to set them on server start. Addendum: Specifically, I was hoping to be able to provide an extra environment variable like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hasura does not run in the same process or in the same machine as your database, so they do not share environments. This only works for mutations. Queries can access the same variable when executing custom SQL functions that receive the session as an argument. I would strongly advise against any of the above for your use case I understand your use case is setting these environment variables on server start, but the question is which server? I would encourage you to instead set these env vars in your database server, on server start. |
Beta Was this translation helpful? Give feedback.
Hasura does not run in the same process or in the same machine as your database, so they do not share environments.
The closest you can do: set the env var as part of the session, (either via JWT or webhook auth mode), and access them in SQL with the rest of your session: https://hasura.io/docs/latest/graphql/core/guides/auditing-tables/
This only works for mutations. Queries can access the same variable when executing custom SQL functions that receive the session as an argument.
I would strongly advise against any of the above for your use case
I understand your use case is setting these environment variables on server start, but the question is which server?
Your hasura instance does no…