BigQuery: Customise auto-generated field names

Introduction

Hasura auto-generates GraphQL field names based on your database table and column names. If you’d like to change the defaults, it is possible to override and rename the auto-generated table and column field names exposed over the GraphQL API.

Supported from

This feature is supported in versions v2.0.8 and later.

Expose columns with a different name in the GraphQL API

Console support coming soon

You can customize auto-generated field names in the tables.yaml file inside the metadata directory:

 - table:
     dataset: hasura
     name: author
   configuration:
     custom_column_names:
       addr: address

Apply the metadata by running:

hasura metadata apply

A custom field name can be set for a column via the following 2 methods:

  1. Passing a Table Config with the CustomColumnNames to the bigquery_set_table_customization API while tracking a table:

    POST /v1/metadata HTTP/1.1
    Content-Type: application/json
    X-Hasura-Role: admin
    
    {
      "type": "bigquery_set_table_customization",
      "args": {
        "table": "authors",
        "configuration": {
          "custom_column_names": {
            "id": "AuthorId"
          }
        }
      }
    }
    
  2. Customization can be done at the time of creation using bigquery_track_table API also.

Expose table root fields with a different name in the GraphQL API

Console support coming soon

You can expose table root fields with a different name in the GraphQL API in the tables.yaml file inside the metadata directory:

 - table:
     dataset: hasura
     name: authors
   configuration:
     custom_root_fields:
       select: authors_aggregate

After that, apply the metadata by running:

hasura metadata apply

A custom field name can be set for a table root field via the following 2 methods:

  1. Passing a Table Config with the Custom Root Fields to the bigquery_set_table_customization API while tracking a table:

    POST /v1/metadata HTTP/1.1
    Content-Type: application/json
    X-Hasura-Role: admin
    
    {
      "type": "bigquery_set_table_customization",
      "args": {
        "table": "authors",
        "configuration": {
          "custom_column_names": {
            "id": "AuthorId"
          }
          "custom_root_fields": {
            "select": "authors",
            "select_aggregate": "authors_aggregate"
          }
        }
      }
    }
    
  2. Customization can be done at the time of creation using bigquery_track_table API also.