Convox Community

Interpolating resource urls into environment


I’m using Hasura and wish to use a rack-level resource URL in an environment variable.

The resource is named ‘database’ so it is given the variable name DATABASE_URL.

Hasura expects the database configuration env to be HASURA_GRAPHQL_DATABASE_URL so I attempt to interpolate using:

      - database

This results in no value being set in HASURA_GRAPHQL_DATABASE_URL.

How can I use the value of the resource in a different environmental variable? I’ve not used Hasura before but a quick look at their docs and source code seems to indicate a slightly easier configuration mechanism is available to you here. I’m assuming that you are using the pre-built hasura docker file as a service here… But setting up your service in convox.yml roughly like this:

    image: hasura/graphql-engine:latest
      - database
    command: graphql-engine --database-url ${DATABASE_URL} serve

Should expand/interpolate the database URL when constructing the command for deployment and result in telling Hasura where the graphql-engine program needs to go to find its database.

If you have any other things to setup/pass through, they may have similar flags. The command line flags are documented here:

Hope this helps a bit. :slight_smile:

1 Like

We have a blog post to show how you can get Hasura up and working: including a sample convox.yml !
You can name your resource as hasura_graphql_database and it will automatically work then :blush:

Hope that helps too!