BigQuery: Customize 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.
This feature is supported in versions v2.0.8
and later.
Expose columns with a different name in the GraphQL API
- Console
- CLI
- 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:
column_config:
addr:
custom_name: address
Apply the Metadata by running:
hasura metadata apply
A custom field name can be set for a column via the following 2 methods:
Passing a Table Config with the ColumnConfig 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": {
"source": "<db_name>",
"table": "authors",
"configuration": {
"column_config": {
"id": {
"custom_name": "AuthorId"
}
}
}
}
}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
- CLI
- 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:
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": {
"source": "<db_name>",
"table": "authors",
"configuration": {
"column_config": {
"id": {
"custom_name": "AuthorId"
}
},
"custom_root_fields": {
"select": "authors",
"select_aggregate": "authors_aggregate"
}
}
}
}Customization can be done at the time of creation using bigquery_track_table API also.