Free tier launching soon. Star our Github repo to keep up to date. 🙌
2020-09-07

How to programatically track tables with Hasura

elitasson
Johan Eliasson

To programatically track a table in Hasura you need the Hasura endpoint and the Hasura admin-secret.

Then make a POST requst to https://hasura-endpoint.io/v1/query with this payload:

{
  "type": "track_table",
  "args": {
    "schema": "public",
    "name": "customers"
  }
}

You can also use Hasura's second version for tracking tables. This version allows you to set more configuration options for the tracked table.

{
  "type": "track_table",
  "version": 2,
  "args": {
    "table": "customers",
    "configuration": {
      "custom_root_fields": {
        "select": "Customers",
        "select_by_pk": "Customer",
        "select_aggregate": "CustomersAggregate",
        "insert": "AddCustomers",
        "insert_one": "AddCustomer",
        "update": "UpdateCustomers",
        "update_by_pk": "UpdateCustomer",
        "delete": "DeleteCustomers",
        "delete_by_pk": "DeleteCustomer"
      },
      "custom_column_names": {
        "id": "customerId"
      }
    }
  }
}

Once the table is tracked, it's available over the GraphQL API.

What's next?
Did you find this blog post interesting? Follow Nhost on Twitter.
Subscribe to the newsletter
Future of app development - stay up-to-date.
Try Nhost for Free Today
Focus on your app and your users!

Serverless backend for modern web and mobile apps

© Nhost
githubtwitterdiscordyoutubelinkedin