What is Hasura
When I say Hasura, I mean the Hasura GraphQL engine, which they describe as a way to "setup a GraphQL server and event triggers over a Postgres database in minutes".
Getting started with Hasura
To quickly get set up using Hasura I followed this guide - it quickly sets up a User table, so you can get querying, like so:
Once that's working I then secured my endpoint following this guide - you can never be too careful!
Testing in OnlineOrNot
- To start testing on OnlineOrNot, we'll need to define a new Application, as follows:
- Once the Application is defined, we're ready to create a new Test. To do this I copied the query, variables and header information I needed out of Hasura. Take special note to add
"X-Hasura-Access-Key"to the Headers field if you secured your endpoint. Once the Application, Query, Variables and Headers fields are filled out you can click the "Test" button to retrieve an Expected Result from Hasura. After you've filled out the relevant fields, hit Submit and wait a few minutes for OnlineOrNot to begin testing.
- After a minute, OnlineOrNot will start regularly testing the Hasura endpoint to ensure the returned value matches your initial setup value:
- After a few more minutes, the performance dashboard at the Home screen will start showing data:
If we wanted to take this one step further and add Slack notifications for every time the GraphQL query takes too long to respond, or responds with unexpected data (because someone on your team edited a record, or changed the value a resolver returns), we can!
- In OnlineOrNot, we go back to the Applications view, and click on our Hasura Application:
- On this screen we can add a Slack integration:
- If we wanted to modify which events to send notifications for, we go back to the Tests view, click on our Hasura test, and uncheck the notifications you no longer wish to receive:
If you've made it this far, you've managed to fully automate GraphQL testing against your server, with downtime notifications! Congrats!