We use the Hasura GraphQL engine to power the interface between the frontend and all of our backend services.
- Docker Compose
- Hasura CLI
- Full Setup: A SendGrid account per instructions in the main README.
cp hasura/.env.example hasura/.env.local
- In
hasura/.env.local
set the value ofHASURA_GRAPHQL_ADMIN_SECRET
to the Hasura admin secret value generated at the beginning of this setup process. Set the value ofEVENT_SECRET
to another secure random value. - Run the
Hasura Console -- Local Development
task within VSCode:Terminal > Run Task
. This will start the GraphQL engine in Docker first, and that VSCode task will prompt for a Docker project name with a default filled in. Press enter to accept the default.- If you find that the Docker container runs out of memory or crashes on first startup, then we recommend applying the migrations and writing the Hasura metadata sequentially. To do this, comment out the
volume
./hasura/metadata:/hasura-metadata
indocker-compose.yaml
and run theHasura Console -- Local Development
task. Once complete, uncomment./hasura/metadata:/hasura-metadata
and runHasura Console -- Local Development
again.
- If you find that the Docker container runs out of memory or crashes on first startup, then we recommend applying the migrations and writing the Hasura metadata sequentially. To do this, comment out the
- Check that the Docker Compose task ran successfully in the Task Output
- If you get an error from this task, make sure the Docker app is running first!
- Check that the Hasura Console task ran successfully in the Task Output
- If you get an error message about
version check: failed to get version from server: failed making version api call...
try running the task again -- there is a race condition that can cause this.
- If you get an error message about
- Your browser should have opened a tab to the Hasura Console. Open the
system.Configuration
table (click the DATA tab at top, expand thesystem
schema on the left, and click theConfiguration
table) and insert the rows listed below. Production: If running Midspace in a production environment, you will need to insert rows into thesystem.Configuration
table for all available keys, not just those listed here. Refer to thedescription
field of each key (insystem.ConfigurationKey
) for expected values for the remaining keys.Key Value SENDGRID_API_KEY
your SendGrid API key, as a JSON string (i.e. wrapped in double quotes) SENDGRID_WEBHOOK_PUBLIC_KEY
your SendGrid webhook signed requests public key, as a JSON string (i.e. wrapped in double quotes) SENDGRID_SENDER
the 'from' email address you wish to use for emails sent by Midspace, as a JSON string SENDGRID_REPLYTO
the 'reply-to' email address you wish to use for emails sent by Midspace, as a JSON string HOST_ORGANISATION_NAME
Name of your organization to appear in email footers, as a JSON string STOP_EMAILS_CONTACT_EMAIL_ADDRESS
Contact address for emails received in error, as a JSON string DEFAULT_FRONTEND_HOST
Either http://localhost:3000
or your public frontend URL, as a JSON string
Now return to the main README.
See root ReadMe instructions for local development for which tasks to run.
Note: If the environment configuration for Hasura/Postgres or the Docker Compose configuration change, then the Hasura local-dev tasks will need to be restarted (which will also apply the changes to Docker).
We use GitHub Actions (a.k.a. Workflows) to automatically deploy new versions to Hasura Cloud and run migrations.
Branch | Hasura Cloud Instance |
---|---|
develop | ci-testing |
staging | staging |
main | production |
Name | Purpose |
---|---|
.env.local |
Local development |
.env.ci-test |
Hasura Console connection to Hasura Cloud for managing the CI instance |
.env.staging |
Hasura Console connection to Hasura Cloud for managing the staging instance |
.env.production |
Hasura Console connection to Hasura Cloud for managing the production instance |
Env Var | Value |
---|---|
HASURA_GRAPHQL_ADMIN_SECRET | A secure random value |
HASURA_GRAPHQL_DATABASE_URL | Allow Hasura to configure this |
ACTION_BASE_URL | The Heroku Actions Service uri - no trailing slash |
REALTIME_BASE_URL | The Heroku Presence Service uri - no trailing slash |
EVENT_SECRET | The secret to be sent for event trigger auth |
HASURA_GRAPHQL_UNAUTHORIZED_ROLE | unauthenticated |