Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
chrisnurse edited this page Mar 24, 2019 · 4 revisions

Welcome to the hasura-auto-tracker WIKI!

You can view the release notes here: RELEASE NOTES

Getting started

It is very straightforward to get started with hasura-auto-tracker. All you need is a database and hasura already setup.

This quick start guide will give you a complete end to end walkthrough of setting up a database complete with test data, connecting with hasura and running hasura-auto-tracker.

This walkthrough comprises the following steps:

  • Pull the repo to your local machine
  • Locate the init_db.sql file and copy the contents to your clipboard
  • Navigate to the Hasura console/data tab
  • Click the large "SQL" button in the navigation on the left of the screen
  • Paste the SQL code into the SQL box in the Hasura user interface
  • Scroll to the bottom of the screen
  • Ensure cascade metadata and Track this are both UNSELECTED
  • Click RUN!

Go back to the Data Tab - the whole point is that you can see the list of tables and views but nothing is tracked. Normally you would have to manually click the tracking buttons

Go to your command line and ensure you are in the local folder where you have pulled the repo and type:

yarn start

This will load run_hat.js, which in turn loads the configuration and executes the hasura-auto-tracker

Once the process is compeleted, which is very quick, return to the DATA TAB in Hasura UI and refresh the page

Ensure that the hasura_test schema is selected.

You will now see that the tables and relationship are tracked. You will also see that a VIEW has been created json_data.

Click on the json_data view, then select RELATIONSHIPS, not that hasura-autotracker has created a relationship from json_data to messages.

Execute this query:

{
  hasura_test_customers{name}
}

The database initialisation script gave you some test data.

Now get the customers with their devices... { hasura_test_customers { name customer_devices { name } } }

And now for the grand finale!

How about that JSON data?

{
  hasura_test_json_data{
    messageId
    humidity
    temperature
    windspeed
    winddirection
  }
}

Ok that is nice, but where is our device id?

hasura-auto-tracker created a relationship from the JSON view back to the message table. Hasura already tracked the message and device tables, so all we have to do is ask for more data...so let's get the source message from messages, then the device from whence the message came, and then the name of the device...

{
  hasura_test_json_data {
    messageId
    humidity
    temperature
    windspeed
    winddirection
    sourceMessage {
      messages_device {
        name
      }
    }
  }
}

Thank you for trying out hasura-auto-tracker

Got some great ideas how to improve the project? Become a contributor and let's give back to the fantastic Hasura community!

Clone this wiki locally