Aggregation permissions
Introduction
You can enable access to aggregation queries for a given role on select
operations.
- Console
- CLI
- API
You can enable aggregation queries permissions on the Hasura Console by going to: Data -> [table] -> Permissions -> select -> Aggregation queries permissions and enabling the checkbox as per the below:
You can allow aggregation query permissions in the metadata -> databases -> [database-name] -> tables -> [table-name].yaml
file, eg:
- table:
schema: public
name: products
select_permissions:
- role: user
permission:
columns:
- id
- name
allow_aggregations: true
Apply the Metadata by running:
hasura metadata apply
You can allow aggregation query permissions when using the permissions Metadata API. Example using a Postgres db:
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type": "pg_create_select_permission",
"args": {
"source": "<db_name>",
"table": "products",
"role": "user",
"permission": {
"columns": [],
"filter": {
"id": "X-Hasura-User-Id"
},
"allow_aggregations": true
}
}
}
In the above example, the role user
is allowed to make aggregation queries.