MyGit

v2.8.0-beta.1

hasura/graphql-engine

版本发布时间: 2022-06-08 20:06:40

hasura/graphql-engine最新发布版本:v2.44.0(2024-10-08 18:36:54)

Changelog

Disabling query/subscription root fields

(closes https://github.com/hasura/graphql-engine/issues/696)

When a table is tracked in graphql-engine, three root fields are generated automatically namely <table>, <table>_by_pk and <table>_aggregate in the query and the subscription root. You can now control which root fields are exposed for a given role by specifying them in the select permission.

The main use-case for this feature is to disable APIs that access the table directly but which still need to be tracked so that:

  1. It can be accessed via a relationship to another table
  2. It can be used in select permissions for another table via a relationship

For such use-cases, we can disable all the root fields of the given table. This can be done by setting the select permission as follows:

{
   "role": "user",
   "permission": {
     "columns": [
       "id",
       "name"
     ],
     "filter": {},
     "allow_aggregations": true,
     "query_root_fields": [],
     "subscription_root_fields": []
   }
 }

Another use-case is to allow a role to directly access a table only through its primary key value. This can be done by setting the select permission as follows:

{
   "role": "user",
   "permission": {
     "columns": [
       "id",
       "name"
     ],
     "filter": {},
     "allow_aggregations": false,
     "query_root_fields": ["select_by_pk"],
     "subscription_root_fields": ["select_by_pk"]
   }
 }

Note that console support for this permission will be released later.

Introducing naming conventions (experimental)

(closes https://github.com/hasura/graphql-engine/issues/3320)

Now, users can specify the naming convention of the auto-generated names in HGE. Read docs here. This is an experimental feature (enabled by setting HASURA_GRAPHQL_EXPERIMENTAL_FEATURES: naming_convention) and is supported for Postgres databases only for now. There are two naming conventions possible:

Naming Convention Field names Type names Arguments Enum values
hasura-default Snake case Snake case Snake case as defined
graphql-default Camel case Pascal case Camel case Uppercased

Suppose there is a table called my_table and it has columns id, date_of_birth, last_seen, then with graphql-default naming convention we will get the following auto-generated API:

query {
  myTable(orderBy: {dateOfBirth: asc}, limit: 10) {
    id
    dateOfBirth
    lastSeen
  }
}

To configure the naming convention for a source, set the naming convention in source customisation while adding the source:

{
  "resource_version": 2,
  "metadata": {
    "version": 1,
    "sources": [
      {
        "name": "default",
        "kind": "postgres",
        "tables": [],
        "configuration": {},
        "customization": {
          "naming_convention": "graphql-default"
        }
      }
    ]
  }
}

To set the default naming convention globally, use the environment variable HASURA_GRAPHQL_DEFAULT_NAMING_CONVENTION. Note that the global default can be overridden by the source customisation setting mentioned above.

Note: Custom field names and custom table names will override the naming convention (i.e. if the custom table name is my_table and naming_convention is graphql-default, the field names generated will be my_table, my_tableByPk, my_tableAggregate and so on).

Bug fixes and improvements

相关地址:原始地址 下载(tar) 下载(zip)

1、 cli-hasura-darwin-amd64 75.14MB

2、 cli-hasura-darwin-arm64 75.19MB

3、 cli-hasura-linux-amd64 23.45MB

4、 cli-hasura-linux-arm64 22.02MB

5、 cli-hasura-windows-amd64.exe 69.01MB

查看:2022-06-08发行的版本