Create an App
For any Fly application, you need to reserve an app name. So let’s create an app usingflyctl the command line for Fly.
flyctl, you’ll need to install it. Check out our Install Flyctl guide. If you haven’t got a Fly account yet, run flyctl auth signup to get your own free account.
You will be asked for an app name at this point. Hit return to have one auto-generated for you. You’ll see the app name when the create has been completed like this:
still-dust-14.
Set the Stage
Now, before we deploy Hasura, there’s one more step for a smooth deployment. We are going to set some environment variables and secrets in the app. In particular, we’re going to pass over our database URL to the soon to be deployed application. For this we useflyctl secrets set.
HASURA_GRAPHQL_ENABLE_CONSOLE environment variable, set to true, will allow you to log in to Hasura’s interactive console where you can create queries.
Now, technically this whole step could take place after the app had deployed but that would mean allowing the app to spin its wheels looking for a database until we did set the values. This way, Hasura can start running properly as soon as it is deployed.
Fly Deploy
We can now deploy Hasura. We’ll use the -i option offlyctl deploy which allows you to install publicly available images from Docker hub.
flyctl info will give the details of our Hasura instance:
still-dust-14.fly.dev.
Connecting to Hasura
Open your browser and go to the/console path on that host - still-dust-14.fly.dev/console. You’ll be prompted for the admin secret we set in the secrets and once entered, you’ll be in Hasura’s GraphQL console. From there, you’ll be able to create new tables in PostgreSQL, track existing tables and model your GraphQL API. Once you’ve done that, you can then create GraphQL queries. Of course, this wouldn’t be how you would use Hasura day to day. You’d likely be using it as a GraphQL proxy for your applications.