How to programatically track tables with Hasura

elitasson's avatar on Twitter
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.

Try Nhost for Free Today

Get a perfect backend with Hasura
Get started