mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
docs: update sql server api reference
https://github.com/hasura/graphql-engine-mono/pull/1609 Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com> GitOrigin-RevId: a6cae8da4e7d050ce77806ebd9ca6433c2f1241e
This commit is contained in:
parent
6c48babc95
commit
f9a107ad56
@ -247,6 +247,101 @@ The various types of queries are listed in the following table:
|
||||
- 1
|
||||
- Invoke a trigger with custom payload on a Postgres table
|
||||
|
||||
* - :ref:`mssql_add_source <mssql_add_source>`
|
||||
- :ref:`mssql_add_source_args <mssql_add_source_syntax>`
|
||||
- 1
|
||||
- Add an MS SQL Server database
|
||||
|
||||
* - :ref:`mssql_drop_source <mssql_drop_source>`
|
||||
- :ref:`mssql_drop_source_args <mssql_drop_source_syntax>`
|
||||
- 1
|
||||
- Remove an MS SQL Server database
|
||||
|
||||
* - :ref:`mssql_track_table <mssql_track_table>`
|
||||
- :ref:`mssql_track_table_args <mssql_track_table_syntax>`
|
||||
- 1
|
||||
- Add an MS SQL Server table/view with configuration
|
||||
|
||||
* - :ref:`mssql_untrack_table`
|
||||
- :ref:`mssql_untrack_table_args <mssql_untrack_table_syntax>`
|
||||
- 1
|
||||
- Remove an MS SQL Server table/view
|
||||
|
||||
* - :ref:`mssql_create_object_relationship`
|
||||
- :ref:`mssql_create_object_relationship_args <mssql_create_object_relationship_syntax>`
|
||||
- 1
|
||||
- Define a new object relationship between MS SQL Server tables/views
|
||||
|
||||
* - :ref:`mssql_create_array_relationship`
|
||||
- :ref:`mssql_create_array_relationship_args <mssql_create_array_relationship_syntax>`
|
||||
- 1
|
||||
- Define a new array relationship between MS SQL Server tables/views
|
||||
|
||||
* - :ref:`mssql_drop_relationship`
|
||||
- :ref:`mssql_drop_relationship_args <mssql_drop_relationship_syntax>`
|
||||
- 1
|
||||
- Drop an existing MS SQL Server relationship
|
||||
|
||||
* - :ref:`mssql_rename_relationship`
|
||||
- :ref:`mssql_rename_relationship_args <mssql_rename_relationship_syntax>`
|
||||
- 1
|
||||
- Modify name of an existing MS SQL Server relationship
|
||||
|
||||
* - :ref:`mssql_set_relationship_comment`
|
||||
- :ref:`mssql_set_relationship_comment_args <mssql_set_relationship_comment_syntax>`
|
||||
- 1
|
||||
- Set comment on an existing MS SQL Server relationship
|
||||
|
||||
* - :ref:`mssql_set_table_customization <mssql_set_table_customization>`
|
||||
- :ref:`mssql_set_table_customization_args <mssql_set_table_customization_syntax>`
|
||||
- 1
|
||||
- Set table customization of an already tracked MS SQL Server table
|
||||
|
||||
* - :ref:`mssql_create_insert_permission`
|
||||
- :ref:`mssql_create_insert_permission_args <mssql_create_insert_permission_syntax>`
|
||||
- 1
|
||||
- Specify insert permission for an MS SQL Server table/view
|
||||
|
||||
* - :ref:`mssql_drop_insert_permission`
|
||||
- :ref:`mssql_drop_insert_permission_args <mssql_drop_insert_permission_syntax>`
|
||||
- 1
|
||||
- Remove existing insert permission for an MS SQL Server table/view
|
||||
|
||||
* - :ref:`mssql_create_select_permission`
|
||||
- :ref:`mssql_create_select_permission_args <mssql_create_select_permission_syntax>`
|
||||
- 1
|
||||
- Specify select permission for an MS SQL Server table/view
|
||||
|
||||
* - :ref:`mssql_drop_select_permission`
|
||||
- :ref:`mssql_drop_select_permission_args <mssql_drop_select_permission_syntax>`
|
||||
- 1
|
||||
- Remove existing select permission for an MS SQL Server table/view
|
||||
|
||||
* - :ref:`mssql_create_update_permission`
|
||||
- :ref:`mssql_create_update_permission_args <mssql_create_update_permission_syntax>`
|
||||
- 1
|
||||
- Specify update permission for an MS SQL Server table/view
|
||||
|
||||
* - :ref:`mssql_drop_update_permission`
|
||||
- :ref:`mssql_drop_update_permission_args <mssql_drop_update_permission_syntax>`
|
||||
- 1
|
||||
- Remove existing update permission for an MS SQL Server table/view
|
||||
|
||||
* - :ref:`mssql_create_delete_permission`
|
||||
- :ref:`mssql_create_delete_permission_args <mssql_create_delete_permission_syntax>`
|
||||
- 1
|
||||
- Specify delete permission for an MS SQL Server table/view
|
||||
|
||||
* - :ref:`mssql_drop_delete_permission`
|
||||
- :ref:`mssql_drop_delete_permission_args <mssql_drop_delete_permission_syntax>`
|
||||
- 1
|
||||
- Remove existing delete permission for an MS SQL Server table/view
|
||||
|
||||
* - :ref:`mssql_set_permission_comment`
|
||||
- :ref:`mssql_set_permission_comment_args <mssql_set_permission_comment_syntax>`
|
||||
- 1
|
||||
- Set comment on an existing permission for an MS SQL Server table/view
|
||||
|
||||
* - :ref:`metadata_create_cron_trigger`
|
||||
- :ref:`create_cron_trigger_args <metadata_create_cron_trigger_syntax>`
|
||||
- 1
|
||||
@ -433,6 +528,66 @@ The various types of queries are listed in the following table:
|
||||
- 1
|
||||
- Set graphql introspection options
|
||||
|
||||
|
||||
.. TODO: MSSQL_UNSUPPORTED
|
||||
|
||||
* - :ref:`mssql_set_table_is_enum`
|
||||
- :ref:`mssql_set_table_is_enum_args <mssql_set_table_is_enum_syntax>`
|
||||
- 1
|
||||
- Set a tracked MS SQL Server table as an enum table
|
||||
|
||||
* - :ref:`mssql_track_function`
|
||||
- :ref:`mssql_track_function_args <mssql_track_function_syntax>`
|
||||
- 1
|
||||
- Add an MS SQL Server SQL function with configuration
|
||||
|
||||
* - :ref:`mssql_untrack_function`
|
||||
- :ref:`FunctionName <FunctionName>`
|
||||
- 1
|
||||
- Remove an MS SQL Server SQL function
|
||||
|
||||
* - :ref:`mssql_create_function_permission`
|
||||
- :ref:`mssql_create_function_permission_args <mssql_create_function_permission_syntax>`
|
||||
- 1
|
||||
- Create an MS SQL Server function permission
|
||||
|
||||
* - :ref:`mssql_drop_function_permission`
|
||||
- :ref:`mssql_drop_function_permission_args <mssql_drop_function_permission_syntax>`
|
||||
- 1
|
||||
- Drop an existing MS SQL Server function permission
|
||||
|
||||
* - :ref:`mssql_add_computed_field`
|
||||
- :ref:`mssql_add_computed_field_args <mssql_add_computed_field_syntax>`
|
||||
- 1
|
||||
- Add a computed field to an MS SQL Server table/view
|
||||
|
||||
* - :ref:`mssql_drop_computed_field`
|
||||
- :ref:`mssql_drop_computed_field_args <mssql_drop_computed_field_syntax>`
|
||||
- 1
|
||||
- Drop an MS SQL Server computed field
|
||||
|
||||
|
||||
* - :ref:`mssql_create_event_trigger`
|
||||
- :ref:`mssql_create_event_trigger_args <mssql_create_event_trigger_syntax>`
|
||||
- 1
|
||||
- Create or replace an event trigger on an MS SQL Server table
|
||||
|
||||
* - :ref:`mssql_delete_event_trigger`
|
||||
- :ref:`mssql_delete_event_trigger_args <mssql_delete_event_trigger_syntax>`
|
||||
- 1
|
||||
- Delete an existing event trigger on an MS SQL Server table
|
||||
|
||||
* - :ref:`mssql_redeliver_event`
|
||||
- :ref:`mssql_redeliver_event_args <mssql_redeliver_event_syntax>`
|
||||
- 1
|
||||
- Redeliver an existing event on an MS SQL Server table
|
||||
|
||||
* - :ref:`mssql_invoke_event_trigger`
|
||||
- :ref:`mssql_invoke_event_trigger_args <mssql_invoke_event_trigger_syntax>`
|
||||
- 1
|
||||
- Invoke a trigger with custom payload on an MS SQL Server table
|
||||
|
||||
|
||||
**See:**
|
||||
|
||||
- :ref:`Tables/Views <metadata_api_tables_views>`
|
||||
|
@ -639,3 +639,610 @@ Args syntax
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_create_insert_permission:
|
||||
|
||||
mssql_create_insert_permission
|
||||
------------------------------
|
||||
|
||||
An insert permission is used to enforce constraints on the data that is being
|
||||
inserted.
|
||||
|
||||
Let's look at an example, a permission for the ``user`` role to insert into the
|
||||
``article`` table. What is the constraint that we would like to enforce here? *A
|
||||
user can only insert articles for themselves* .
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type" : "mssql_create_insert_permission",
|
||||
"args" : {
|
||||
"table" : "article",
|
||||
"source": "default",
|
||||
"role" : "user",
|
||||
"permission" : {
|
||||
"check" : {
|
||||
"author_id" : "X-HASURA-USER-ID"
|
||||
},
|
||||
"set":{
|
||||
"id":"X-HASURA-USER-ID"
|
||||
},
|
||||
"columns":["name","author_id"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
This reads as follows - for the ``user`` role:
|
||||
|
||||
* For every row that is being inserted into the *article* table, allow insert only if the ``check`` passes i.e. that the ``author_id`` column value is the same as the value in the request header ``X-HASURA-USER-ID``".
|
||||
|
||||
* If the above ``check`` passes, then access for insert will be limited to columns ``name`` and ``author_id`` only.
|
||||
|
||||
* When this insert happens, the value of the column ``id`` will be automatically ``set`` to the value of the resolved session variable ``X-HASURA-USER-ID``.
|
||||
|
||||
|
||||
The argument for ``check`` is a boolean expression which has the same syntax as the ``where`` clause in the ``select`` query, making it extremely expressive.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type" : "mssql_create_insert_permission",
|
||||
"args" : {
|
||||
"table" : "article",
|
||||
"source": "default",
|
||||
"role" : "user",
|
||||
"permission" : {
|
||||
"check" : {
|
||||
"author_id" : "X-HASURA-USER-ID",
|
||||
"$or" : [
|
||||
{
|
||||
"category" : "editorial",
|
||||
"is_reviewed" : false
|
||||
},
|
||||
{
|
||||
"category" : { "$neq" : "editorial"}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
In the above definition, the row is allowed to be inserted if the ``author_id``
|
||||
is the same as the request's user id and ``is_reviewed`` is ``false`` when the
|
||||
``category`` is "editorial".
|
||||
|
||||
.. _mssql_create_insert_permission_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - role
|
||||
- true
|
||||
- :ref:`RoleName`
|
||||
- Role
|
||||
* - permission
|
||||
- true
|
||||
- :ref:`InsertPermission`
|
||||
- The permission definition
|
||||
* - comment
|
||||
- false
|
||||
- text
|
||||
- Comment
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_drop_insert_permission:
|
||||
|
||||
mssql_drop_insert_permission
|
||||
----------------------------
|
||||
|
||||
The ``mssql_drop_insert_permission`` API is used to drop an existing insert permission for a role on a table.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type" : "mssql_drop_insert_permission",
|
||||
"args" : {
|
||||
"table" : "article",
|
||||
"source": "default",
|
||||
"role" : "user"
|
||||
}
|
||||
}
|
||||
|
||||
.. _mssql_drop_insert_permission_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - role
|
||||
- true
|
||||
- :ref:`RoleName`
|
||||
- Role
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_create_select_permission:
|
||||
|
||||
mssql_create_select_permission
|
||||
------------------------------
|
||||
|
||||
A select permission is used to restrict access to only the specified columns and rows.
|
||||
|
||||
Let's look at an example, a permission for the ``user`` role to select from the
|
||||
``article`` table: all columns can be read, as well as the rows that have been published or
|
||||
authored by the user themselves.
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type" : "mssql_create_select_permission",
|
||||
"args" : {
|
||||
"table" : "article",
|
||||
"role" : "user",
|
||||
"source": "default",
|
||||
"permission" : {
|
||||
"columns" : "*",
|
||||
"filter" : {
|
||||
"$or" : [
|
||||
{ "author_id" : "X-HASURA-USER-ID" },
|
||||
{ "is_published" : true }
|
||||
]
|
||||
},
|
||||
"limit": 10,
|
||||
"allow_aggregations": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
This reads as follows - For the ``user`` role:
|
||||
|
||||
* Allow selecting rows where the ``check`` passes i.e. ``is_published`` is ``true`` or the ``author_id`` matches the value of the session variable ``X-HASURA-USER-ID``.
|
||||
|
||||
* Allow selecting all columns (because the ``columns`` key is set to ``*``).
|
||||
|
||||
* ``limit`` the numbers of rows returned by a query to the ``article`` table by the ``user`` role to a maximum of 10.
|
||||
|
||||
* Allow aggregate queries.
|
||||
|
||||
.. _mssql_create_select_permission_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - role
|
||||
- true
|
||||
- :ref:`RoleName`
|
||||
- Role
|
||||
* - permission
|
||||
- true
|
||||
- :ref:`SelectPermission`
|
||||
- The permission definition
|
||||
* - comment
|
||||
- false
|
||||
- text
|
||||
- Comment
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_drop_select_permission:
|
||||
|
||||
mssql_drop_select_permission
|
||||
----------------------------
|
||||
|
||||
The ``mssql_drop_select_permission`` is used to drop an existing select permission for a role on a table.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type" : "mssql_drop_select_permission",
|
||||
"args" : {
|
||||
"table" : "article",
|
||||
"role" : "user",
|
||||
"source": "default"
|
||||
}
|
||||
}
|
||||
|
||||
.. _mssql_drop_select_permission_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - role
|
||||
- true
|
||||
- :ref:`RoleName`
|
||||
- Role
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_create_update_permission:
|
||||
|
||||
mssql_create_update_permission
|
||||
------------------------------
|
||||
|
||||
An update permission is used to restrict the columns and rows that can be
|
||||
updated. Its structure is quite similar to the select permission.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type" : "mssql_create_update_permission",
|
||||
"args" : {
|
||||
"table" : "article",
|
||||
"source": "default",
|
||||
"role" : "user",
|
||||
"permission" : {
|
||||
"columns" : ["title", "content", "category"],
|
||||
"filter" : {
|
||||
"author_id" : "X-HASURA-USER-ID"
|
||||
},
|
||||
"check" : {
|
||||
"content" : {
|
||||
"_ne": ""
|
||||
}
|
||||
},
|
||||
"set":{
|
||||
"updated_at" : "NOW()"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
This reads as follows - for the ``user`` role:
|
||||
|
||||
* Allow updating only those rows where the ``filter`` passes i.e. the value of the ``author_id`` column of a row matches the value of the session variable ``X-HASURA-USER-ID``.
|
||||
|
||||
* If the above ``filter`` passes for a given row, allow updating only the ``title``, ``content`` and ``category`` columns (*as specified in the* ``columns`` *key*).
|
||||
|
||||
* After the update happens, verify that the ``check`` condition holds for the updated row i.e. that the value in the ``content`` column is not empty.
|
||||
|
||||
* When this update happens, the value of the column ``updated_at`` will be automatically ``set`` to the current timestamp.
|
||||
|
||||
.. note::
|
||||
|
||||
It is important to deny updates to columns that will determine the row
|
||||
ownership. In the above example, the ``author_id`` column determines the
|
||||
ownership of a row in the ``article`` table. Columns such as this should
|
||||
never be allowed to be updated.
|
||||
|
||||
.. _mssql_create_update_permission_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - role
|
||||
- true
|
||||
- :ref:`RoleName`
|
||||
- Role
|
||||
* - permission
|
||||
- true
|
||||
- :ref:`UpdatePermission`
|
||||
- The permission definition
|
||||
* - comment
|
||||
- false
|
||||
- text
|
||||
- Comment
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_drop_update_permission:
|
||||
|
||||
mssql_drop_update_permission
|
||||
----------------------------
|
||||
|
||||
The ``mssql_drop_update_permission`` API is used to drop an existing update permission for a role on a table.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type" : "mssql_drop_update_permission",
|
||||
"args" : {
|
||||
"table" : "article",
|
||||
"source": "default",
|
||||
"role" : "user"
|
||||
}
|
||||
}
|
||||
|
||||
.. _mssql_drop_update_permission_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - role
|
||||
- true
|
||||
- :ref:`RoleName`
|
||||
- Role
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_create_delete_permission:
|
||||
|
||||
mssql_create_delete_permission
|
||||
------------------------------
|
||||
|
||||
A delete permission is used to restrict the rows that can be deleted.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type" : "mssql_create_delete_permission",
|
||||
"args" : {
|
||||
"table" : "article",
|
||||
"source": "default",
|
||||
"role" : "user",
|
||||
"permission" : {
|
||||
"filter" : {
|
||||
"author_id" : "X-HASURA-USER-ID"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
This reads as follows:
|
||||
|
||||
"``delete`` for the ``user`` role on the ``article`` table is allowed on rows where
|
||||
``author_id`` is the same as the request header ``X-HASURA-USER-ID`` value."
|
||||
|
||||
.. _mssql_create_delete_permission_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - role
|
||||
- true
|
||||
- :ref:`RoleName`
|
||||
- Role
|
||||
* - permission
|
||||
- true
|
||||
- :ref:`DeletePermission`
|
||||
- The permission definition
|
||||
* - comment
|
||||
- false
|
||||
- text
|
||||
- Comment
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_drop_delete_permission:
|
||||
|
||||
mssql_drop_delete_permission
|
||||
----------------------------
|
||||
|
||||
The ``mssql_drop_delete_permission`` API is used to drop an existing delete permission for a role on a table.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type" : "mssql_drop_delete_permission",
|
||||
"args" : {
|
||||
"table" : "article",
|
||||
"role" : "user",
|
||||
"source": "default"
|
||||
}
|
||||
}
|
||||
|
||||
.. _mssql_drop_delete_permission_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - role
|
||||
- true
|
||||
- :ref:`RoleName`
|
||||
- Role
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_set_permission_comment:
|
||||
|
||||
mssql_set_permission_comment
|
||||
----------------------------
|
||||
|
||||
``mssql_set_permission_comment`` is used to set/update the comment on a permission.
|
||||
Setting the comment to ``null`` removes it.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer <auth-token> # optional if cookie is set
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_set_permission_comment",
|
||||
"args": {
|
||||
"table": "article",
|
||||
"source": "default",
|
||||
"role": "user",
|
||||
"type" : "update",
|
||||
"comment" : "can only modify his/her own rows"
|
||||
}
|
||||
}
|
||||
|
||||
.. _mssql_set_permission_comment_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - role
|
||||
- true
|
||||
- :ref:`RoleName`
|
||||
- The role in the permission
|
||||
* - type
|
||||
- true
|
||||
- permission type (one of select/update/delete/insert)
|
||||
- The type of the permission
|
||||
* - comment
|
||||
- false
|
||||
- Text
|
||||
- Comment
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
@ -119,10 +119,13 @@ Create an ``object relationship`` ``details`` on ``author`` *table*, *using* the
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
"foreign_key_constraint_on" : {
|
||||
"table": "author_details",
|
||||
"column": "author_id"
|
||||
}
|
||||
{
|
||||
"foreign_key_constraint_on" : {
|
||||
"table": "author_details",
|
||||
"column": "author_id"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
This form is deprecated in favor of the more general ``columns`` field.
|
||||
|
||||
@ -255,10 +258,12 @@ Create an ``array relationship`` ``articles`` on ``author`` *table*, *using* th
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
"foreign_key_constraint_on" : {
|
||||
"table": "author_details",
|
||||
"column": "author_id"
|
||||
}
|
||||
{
|
||||
"foreign_key_constraint_on" : {
|
||||
"table": "author_details",
|
||||
"column": "author_id"
|
||||
}
|
||||
}
|
||||
|
||||
This form is deprecated in favor of the more general ``columns`` field.
|
||||
|
||||
@ -513,3 +518,475 @@ Args syntax
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_create_object_relationship:
|
||||
|
||||
mssql_create_object_relationship
|
||||
--------------------------------
|
||||
|
||||
``create_object_relationship`` is used to create an object relationship on a
|
||||
table. There cannot be an existing column or relationship with the same name.
|
||||
|
||||
There are 3 ways in which you can create an object relationship.
|
||||
|
||||
1. Using foreign key constraint on a column
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Create an ``object relationship`` ``author`` on ``article`` *table*, *using* the
|
||||
*foreign_key_constraint_on* the ``author_id`` column:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_create_object_relationship",
|
||||
"args": {
|
||||
"table": "article",
|
||||
"name": "author",
|
||||
"source": "default",
|
||||
"using": {
|
||||
"foreign_key_constraint_on" : ["author_id"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.. note::
|
||||
|
||||
In the case that the key uses only a single column it is permissible to give
|
||||
just a string instead of a list, i.e.: ``"foreign_key_constraint_on" : "author_id"``.
|
||||
|
||||
|
||||
2. Using foreign key constraint on a remote table
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Create an ``object relationship`` ``details`` on ``author`` *table*, *using* the
|
||||
*foreign_key_constraint_on* the ``author_details`` *table*'s ``author_id`` *column*:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "create_object_relationship",
|
||||
"args": {
|
||||
"table": "author",
|
||||
"name": "details",
|
||||
"using": {
|
||||
"foreign_key_constraint_on" : {
|
||||
"table": "author_details",
|
||||
"columns": ["author_id"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.. admonition:: Deprecation
|
||||
|
||||
For compatibility with previous versions we also support the form of
|
||||
``foreign_key_constraint_on`` with a ``column``-field, e.g.:
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"foreign_key_constraint_on" : {
|
||||
"table": "author_details",
|
||||
"column": "author_id"
|
||||
}
|
||||
}
|
||||
|
||||
This form is deprecated in favor of the more general ``columns`` field.
|
||||
|
||||
.. admonition:: Supported from
|
||||
|
||||
Relationships via remote table are supported for versions ``v2.0.0-alpha.3`` and above.
|
||||
|
||||
.. _mssql_manual_obj_relationship:
|
||||
|
||||
3. Manual configuration
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This is an advanced feature which is mostly used to define relationships on or
|
||||
to views. We cannot rely on foreign key constraints as they are not valid to or
|
||||
from views. So, when using manual configuration, we have to specify the remote
|
||||
table and how columns in this table are mapped to the columns of the
|
||||
remote table.
|
||||
|
||||
Let's say we have a view called ``article_detail`` which has three columns
|
||||
``article_id`` and ``view_count`` and ``average_rating``. We can now define an
|
||||
object relationship called ``article_detail`` on the ``article`` table as
|
||||
follows:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_create_object_relationship",
|
||||
"args": {
|
||||
"table": "article",
|
||||
"name": "article_detail",
|
||||
"source": "default",
|
||||
"using": {
|
||||
"manual_configuration" : {
|
||||
"remote_table" : "article_detail",
|
||||
"column_mapping" : {
|
||||
"id" : "article_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.. note::
|
||||
|
||||
It is easy to make mistakes while using ``manual_configuration``.
|
||||
One simple check is to ensure that foreign key constraint semantics are valid
|
||||
on the columns being used in ``column_mapping``. In the previous example, if
|
||||
it was allowed, a foreign key constraint could have been defined on
|
||||
``article`` table's ``id`` column to ``article_detail`` view's ``article_id``
|
||||
column.
|
||||
|
||||
.. _mssql_create_object_relationship_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName <TableName>`
|
||||
- Name of the table
|
||||
* - name
|
||||
- true
|
||||
- :ref:`RelationshipName <RelationshipName>`
|
||||
- Name of the new relationship
|
||||
* - using
|
||||
- true
|
||||
- :ref:`ObjRelUsing`
|
||||
- Use one of the available ways to define an object relationship
|
||||
* - comment
|
||||
- false
|
||||
- text
|
||||
- comment
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_create_array_relationship:
|
||||
|
||||
mssql_create_array_relationship
|
||||
-------------------------------
|
||||
|
||||
``create_array_relationship`` is used to create an array relationship on a
|
||||
table. There cannot be an existing column or relationship with the same name.
|
||||
|
||||
There are 2 ways in which you can create an array relationship.
|
||||
|
||||
1. Using foreign key constraint on a column
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Create an ``array relationship`` ``articles`` on ``author`` *table*, *using* the
|
||||
*foreign_key_constraint_on* the ``author_id`` column of the ``article`` table:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_create_array_relationship",
|
||||
"args": {
|
||||
"table": "author",
|
||||
"name": "articles",
|
||||
"source": "default",
|
||||
"using": {
|
||||
"foreign_key_constraint_on" : {
|
||||
"table" : "article",
|
||||
"columns" : ["author_id"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.. admonition:: Deprecation
|
||||
|
||||
For compatibility with previous version we also support the form of
|
||||
``foreign_key_constraint_on`` with a ``column``-field, e.g.:
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"foreign_key_constraint_on" : {
|
||||
"table": "author_details",
|
||||
"column": "author_id"
|
||||
}
|
||||
}
|
||||
|
||||
This form is deprecated in favor of the more general ``columns`` field.
|
||||
|
||||
|
||||
2. Manual configuration
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This is an advanced feature which is mostly used to define relationships on or
|
||||
to views. We cannot rely on foreign key constraints as they are not valid to or
|
||||
from views. So, when using manual configuration, we have to specify the remote
|
||||
table and how columns in this table are mapped to the columns of the
|
||||
remote table.
|
||||
|
||||
Let's say we have a view called ``article_detail`` which has four columns
|
||||
``author_id``, ``article_id``, ``view_count`` and ``average_rating``. We can now define an
|
||||
array relationship called ``article_details`` on the ``author`` table as
|
||||
follows:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_create_array_relationship",
|
||||
"args": {
|
||||
"table": "author",
|
||||
"name": "article_details",
|
||||
"source": "default",
|
||||
"using": {
|
||||
"manual_configuration" : {
|
||||
"remote_table" : "article_detail",
|
||||
"column_mapping" : {
|
||||
"id" : "author_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.. note::
|
||||
|
||||
It is easy to make mistakes while using ``manual_configuration``.
|
||||
One simple check is to ensure that foreign key constraint semantics are valid
|
||||
on the columns being used in ``column_mapping``. In the previous example, if
|
||||
it was allowed, a foreign key constraint could have been defined on the
|
||||
``author`` table's ``id`` column to ``article_detail`` view's ``author_id``
|
||||
column.
|
||||
|
||||
.. _mssql_create_array_relationship_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - name
|
||||
- true
|
||||
- :ref:`RelationshipName`
|
||||
- Name of the new relationship
|
||||
* - using
|
||||
- true
|
||||
- :ref:`ArrRelUsing`
|
||||
- Use one of the available ways to define an array relationship
|
||||
* - comment
|
||||
- false
|
||||
- text
|
||||
- comment
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_drop_relationship:
|
||||
|
||||
mssql_drop_relationship
|
||||
-----------------------
|
||||
|
||||
``mssql_drop_relationship`` is used to drop a relationship (both object and array) on
|
||||
a table. If there are other objects dependent on this relationship like
|
||||
permissions and query templates, etc., the request will fail and report the dependencies
|
||||
unless ``cascade`` is set to ``true``. If ``cascade`` is set to ``true``, the
|
||||
dependent objects are also dropped.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_drop_relationship",
|
||||
"args": {
|
||||
"table": "article",
|
||||
"source": "default",
|
||||
"relationship": "article_detail"
|
||||
}
|
||||
}
|
||||
|
||||
.. _mssql_drop_relationship_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - relationship
|
||||
- true
|
||||
- :ref:`RelationshipName`
|
||||
- Name of the relationship that needs to be dropped
|
||||
* - cascade
|
||||
- false
|
||||
- Boolean
|
||||
- When set to ``true``, all the dependent items on this relationship are also dropped
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. note::
|
||||
|
||||
Be careful when using ``cascade``. First, try running the request without
|
||||
``cascade`` or ``cascade`` set to ``false``.
|
||||
|
||||
.. _mssql_set_relationship_comment:
|
||||
|
||||
mssql_set_relationship_comment
|
||||
------------------------------
|
||||
|
||||
``mssql_set_relationship_comment`` is used to set/update the comment on a
|
||||
relationship. Setting the comment to ``null`` removes it.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_set_relationship_comment",
|
||||
"args": {
|
||||
"table": "article",
|
||||
"source": "default",
|
||||
"name": "article_detail",
|
||||
"comment" : "has extra information about an article like count etc."
|
||||
}
|
||||
}
|
||||
|
||||
.. _mssql_set_relationship_comment_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - relationship
|
||||
- true
|
||||
- :ref:`RelationshipName`
|
||||
- The relationship
|
||||
* - comment
|
||||
- false
|
||||
- Text
|
||||
- Comment
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_rename_relationship:
|
||||
|
||||
mssql_rename_relationship
|
||||
-------------------------
|
||||
|
||||
``mssql_rename_relationship`` is used to modify the name of an existing relationship.
|
||||
|
||||
An example:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_rename_relationship",
|
||||
"args": {
|
||||
"table": "article",
|
||||
"name": "article_details",
|
||||
"source": "default",
|
||||
"new_name": "article_detail"
|
||||
}
|
||||
}
|
||||
|
||||
.. _mssql_rename_relationship_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName`
|
||||
- Name of the table
|
||||
* - name
|
||||
- true
|
||||
- :ref:`RelationshipName`
|
||||
- The relationship
|
||||
* - new_name
|
||||
- true
|
||||
- :ref:`RelationshipName`
|
||||
- New relationship name
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
@ -77,7 +77,7 @@ An example request as follows:
|
||||
.. _metadata_update_remote_schema:
|
||||
|
||||
update_remote_schema
|
||||
-----------------
|
||||
--------------------
|
||||
|
||||
``update_remote_schema`` is used to update the configuration of a remote schema. If the remote schema URL has changed
|
||||
then it will perform a introspection as well. After introspection, if there are any inconsistencies detected with other
|
||||
|
@ -177,10 +177,12 @@ Args syntax
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the database
|
||||
|
||||
.. _mssql_add_source:
|
||||
|
||||
mssql_add_source
|
||||
----------------
|
||||
|
||||
``mssql_add_source`` is used to connect a MS SQL Server database to Hasura.
|
||||
``mssql_add_source`` is used to connect an MS SQL Server database to Hasura.
|
||||
|
||||
Add a database with name ``mssql1``:
|
||||
|
||||
@ -239,7 +241,7 @@ Args syntax
|
||||
mssql_drop_source
|
||||
-----------------
|
||||
|
||||
``mssql_drop_source`` is used to remove a MS SQL Server database from Hasura.
|
||||
``mssql_drop_source`` is used to remove an MS SQL Server database from Hasura.
|
||||
|
||||
Remove a database with name ``mssql1``:
|
||||
|
||||
|
@ -181,7 +181,6 @@ Args syntax
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
|
||||
.. _pg_set_table_is_enum:
|
||||
|
||||
pg_set_table_is_enum
|
||||
@ -303,3 +302,208 @@ Args syntax
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_track_table:
|
||||
|
||||
mssql_track_table
|
||||
-----------------
|
||||
|
||||
``mssql_track_table`` is used to add a table/view to the GraphQL schema with configuration.
|
||||
You can customise the root field names.
|
||||
|
||||
Add a table/view ``author``:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_track_table",
|
||||
"args": {
|
||||
"table": "author",
|
||||
"source": "default"
|
||||
}
|
||||
}
|
||||
|
||||
.. TODO: MSSQL_UNSUPPORTED
|
||||
|
||||
A table can be tracked with a ``custom name``. This can be useful when a table
|
||||
name is not GraphQL compliant, like ``Users Address``. A ``custom name`` like
|
||||
``users_address`` will complement the ``"Users Address"``
|
||||
table, so that it can be added to the GraphQL schema.
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_track_table",
|
||||
"args": {
|
||||
"table": "Author Details"
|
||||
}
|
||||
}
|
||||
|
||||
.. TODO: MSSQL_UNSUPPORTED
|
||||
|
||||
The GraphQL nodes and typenames
|
||||
that are generated will be according to the ``identifier``. For example, in this case,
|
||||
the nodes generated will be:
|
||||
|
||||
- ``users_address``
|
||||
- ``users_address_one``
|
||||
- ``users_address_aggregate``
|
||||
- ``insert_users_address``
|
||||
- ``insert_users_address_one``
|
||||
- ``update_users_address``
|
||||
- ``update_users_address_by_pk``
|
||||
- ``delete_users_address``
|
||||
- ``delete_users_address_by_pk``
|
||||
|
||||
.. note::
|
||||
|
||||
Hasura GraphQL engine requires the constraint names (if any) of a table to be
|
||||
`GraphQL compliant <https://spec.graphql.org/June2018/#sec-Names>`__ in order to be able to track it.
|
||||
|
||||
.. _mssql_track_table_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName <TableName>`
|
||||
- Name of the table
|
||||
* - configuration
|
||||
- false
|
||||
- :ref:`Table Config <table_config>`
|
||||
- Configuration for the table/view
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_untrack_table:
|
||||
|
||||
mssql_untrack_table
|
||||
-------------------
|
||||
|
||||
``untrack_table`` is used to remove a table/view from the GraphQL schema.
|
||||
|
||||
Remove a table/view ``author``:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_untrack_table",
|
||||
"args": {
|
||||
"table": {
|
||||
"schema": "dbo",
|
||||
"name": "author"
|
||||
},
|
||||
"source": "default",
|
||||
"cascade": true
|
||||
}
|
||||
}
|
||||
|
||||
.. _mssql_untrack_table_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName <TableName>`
|
||||
- Name of the table
|
||||
* - cascade
|
||||
- false
|
||||
- Boolean
|
||||
- When set to ``true``, the effect (if possible) is cascaded to any metadata dependent objects (relationships, permissions, templates)
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
||||
.. _mssql_set_table_customization:
|
||||
|
||||
mssql_set_table_customization
|
||||
-----------------------------
|
||||
|
||||
``mssql_set_table_customization`` allows you to customize any given table with
|
||||
a custom name, custom root fields and custom column names of an already tracked
|
||||
table. This will **replace** the already present customization.
|
||||
|
||||
:ref:`mssql_set_table_custom_fields <set_table_custom_fields>` has been deprecated in
|
||||
favour of this API.
|
||||
|
||||
Set the configuration for a table/view called ``author``:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/metadata HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "mssql_set_table_customization",
|
||||
"args": {
|
||||
"table": "author_details",
|
||||
"source": "default",
|
||||
"configuration": {
|
||||
"identifier": "author",
|
||||
"custom_root_fields": {
|
||||
"select": "Authors",
|
||||
"select_aggregate": "AuthorAggregate",
|
||||
},
|
||||
"custom_column_names": {
|
||||
"id": "authorId"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.. _mssql_set_table_customization_syntax:
|
||||
|
||||
Args syntax
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key
|
||||
- Required
|
||||
- Schema
|
||||
- Description
|
||||
* - table
|
||||
- true
|
||||
- :ref:`TableName <TableName>`
|
||||
- Name of the table
|
||||
* - configuration
|
||||
- false
|
||||
- :ref:`TableConfig <table_config>`
|
||||
- Configuration for the table/view
|
||||
* - source
|
||||
- false
|
||||
- :ref:`SourceName <SourceName>`
|
||||
- Name of the source database of the table (default: ``default``)
|
||||
|
@ -36,7 +36,7 @@ Request structure
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/query HTTP/1.1
|
||||
POST /v2/query HTTP/1.1
|
||||
|
||||
{
|
||||
"type": "<query-type>",
|
||||
|
@ -79,7 +79,7 @@ An example request as follows:
|
||||
.. _update_remote_schema:
|
||||
|
||||
update_remote_schema
|
||||
-----------------
|
||||
--------------------
|
||||
|
||||
``update_remote_schema`` is used to update the configuration of a remote schema. If the remote schema URL has changed
|
||||
then it will perform a introspection as well. After introspection, if there are any inconsistencies detected with other
|
||||
|
@ -243,8 +243,9 @@ The following statement sets an index on ``name`` in the ``authors`` table.
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "schema_run_sql",
|
||||
"type": "run_sql",
|
||||
"args": {
|
||||
"source": "<db-name>",
|
||||
"sql": "<create index statement>"
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,6 @@ Expose columns with a different name in the GraphQL API
|
||||
|
||||
A custom field name can be set for a column via the following 2 methods:
|
||||
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
1. Passing a :ref:`table_config` with the :ref:`CustomColumnNames` to the :ref:`mssql_set_table_customization` API while tracking a table:
|
||||
|
||||
.. code-block:: http
|
||||
@ -83,7 +81,6 @@ Expose columns with a different name in the GraphQL API
|
||||
}
|
||||
}
|
||||
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
2. Customization can be done at the time of creation using :ref:`mssql_track_table` API also.
|
||||
|
||||
@ -128,8 +125,6 @@ Expose table root fields with a different name in the GraphQL API
|
||||
|
||||
A custom field name can be set for a table root field via the following 2 methods:
|
||||
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
1. Passing a :ref:`table_config` with the :ref:`custom_root_fields` to the :ref:`mssql_set_table_customization` API while tracking a table:
|
||||
|
||||
.. code-block:: http
|
||||
@ -154,7 +149,6 @@ Expose table root fields with a different name in the GraphQL API
|
||||
}
|
||||
}
|
||||
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
2. Customization can be done at the time of creation using :ref:`mssql_track_table` API also.
|
||||
|
||||
|
@ -83,6 +83,7 @@ Let's add a foreign-key constraint to the ``author_id`` column in the ``articles
|
||||
{
|
||||
"type": "run_sql",
|
||||
"args": {
|
||||
"source": "<db-name>",
|
||||
"sql": "ALTER TABLE articles ADD FOREIGN KEY (author_id) REFERENCES authors(id);"
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ An existing relationship can be renamed as follows:
|
||||
hasura metadata apply
|
||||
|
||||
.. tab:: API
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
You can rename a relationship by using the :ref:`mssql_rename_relationship metadata API <mssql_rename_relationship>`:
|
||||
|
||||
.. code-block:: http
|
||||
|
@ -83,8 +83,9 @@ Let's say we want to create two simple tables for ``articles`` and ``authors`` s
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "schema_run_sql",
|
||||
"type": "run_sql",
|
||||
"args": {
|
||||
"source": "<db-name>",
|
||||
"sql": "CREATE TABLE articles(id int NOT NULL, title text NOT NULL, content text NOT NULL, rating int NOT NULL, author_id int NOT NULL, PRIMARY KEY (id));"
|
||||
}
|
||||
}
|
||||
@ -128,7 +129,7 @@ In order to expose a table over the GraphQL API, it needs to be **tracked**.
|
||||
hasura metadata apply
|
||||
|
||||
.. tab:: API
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
To track the table and expose it over the GraphQL API, make the following API call to the :ref:`mssql_track_table metadata API <mssql_track_table>`:
|
||||
|
||||
.. code-block:: http
|
||||
@ -141,26 +142,9 @@ In order to expose a table over the GraphQL API, it needs to be **tracked**.
|
||||
"type": "mssql_track_table",
|
||||
"args": {
|
||||
"table": "authors",
|
||||
"configuration": {
|
||||
"custom_name": "authors_table"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.. MSSQLUPDATE
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/query HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "track_table",
|
||||
"args": {
|
||||
"schema": "public",
|
||||
"name": "articles"
|
||||
}
|
||||
}
|
||||
|
||||
Generated GraphQL schema types
|
||||
------------------------------
|
||||
@ -200,7 +184,9 @@ table we just created and tracked:
|
||||
offset: Int
|
||||
order_by: [articles_order_by!]
|
||||
): [articles!]!
|
||||
..
|
||||
|
||||
.. TODO: MSSQL_UNSUPPORTED
|
||||
|
||||
# insert/upsert mutation field
|
||||
insert_articles (
|
||||
objects: [articles_insert_input!]!
|
||||
@ -271,7 +257,8 @@ sample data into the tables first)*
|
||||
}
|
||||
}
|
||||
|
||||
..
|
||||
.. TODO: MSSQL_UNSUPPORTED
|
||||
|
||||
Insert data in the ``author`` table:
|
||||
|
||||
.. graphiql::
|
||||
@ -304,8 +291,3 @@ sample data into the tables first)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.. MSSQLUPDATE
|
||||
.. note::
|
||||
|
||||
author's ``id`` does not need to be passed as an input as it is of type ``serial`` (auto incrementing integer).
|
||||
|
@ -56,7 +56,6 @@ To track a table or a view
|
||||
|
||||
.. tab:: API
|
||||
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
To track a table and expose it over the GraphQL API, use the :ref:`mssql_track_table metadata API <mssql_track_table>`:
|
||||
|
||||
@ -109,7 +108,6 @@ To track all tables and views present in the database
|
||||
|
||||
.. tab:: API
|
||||
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
To track all tables and expose them over the GraphQL API, use the :ref:`mssql_track_table metadata API <mssql_track_table>`:
|
||||
|
||||
@ -125,14 +123,14 @@ To track all tables and views present in the database
|
||||
{
|
||||
"type": "mssql_track_table",
|
||||
"args": {
|
||||
"schema": "public",
|
||||
"schema": "dbo",
|
||||
"name": "<table-name-1>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "mssql_track_table",
|
||||
"args": {
|
||||
"schema": "public",
|
||||
"schema": "dbo",
|
||||
"name": "<table-name-2>"
|
||||
}
|
||||
}
|
||||
@ -206,7 +204,6 @@ To track a foreign-key between two tables in the database
|
||||
|
||||
**Object relationship**
|
||||
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
You can create an object relationship by using the :ref:`mssql_create_object_relationship metadata API <mssql_create_object_relationship>`:
|
||||
|
||||
@ -309,7 +306,6 @@ To track all the foreign-keys of all tables in the database
|
||||
|
||||
.. tab:: API
|
||||
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
You can create multiple relationships by using the :ref:`mssql_create_object_relationship metadata API <mssql_create_object_relationship>`
|
||||
and the :ref:`mssql_create_array_relationship metadata API <mssql_create_array_relationship>`:
|
||||
|
@ -50,7 +50,7 @@ Creating views
|
||||
hasura migrate apply
|
||||
|
||||
.. tab:: API
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
You can add a view by using the :ref:`schema_run_sql metadata API <schema_run_sql>`:
|
||||
|
||||
.. code-block:: http
|
||||
@ -60,8 +60,9 @@ Creating views
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "schema_run_sql",
|
||||
"type": "run_sql",
|
||||
"args": {
|
||||
"source": "<db-name>",
|
||||
"sql": "<create view statement>"
|
||||
}
|
||||
}
|
||||
@ -110,7 +111,7 @@ In order to expose a view over the GraphQL API, it needs to be **tracked**.
|
||||
hasura metadata apply
|
||||
|
||||
.. tab:: API
|
||||
.. TODO: BROKEN_LINK
|
||||
|
||||
To track the view and expose it over the GraphQL API, make the following API call to the :ref:`mssql_track_table metadata API <mssql_track_table>`:
|
||||
|
||||
.. code-block:: http
|
||||
@ -129,21 +130,6 @@ In order to expose a view over the GraphQL API, it needs to be **tracked**.
|
||||
}
|
||||
}
|
||||
|
||||
.. CODEBACKUP
|
||||
.. code-block:: http
|
||||
|
||||
POST /v1/query HTTP/1.1
|
||||
Content-Type: application/json
|
||||
X-Hasura-Role: admin
|
||||
|
||||
{
|
||||
"type": "track_table",
|
||||
"args": {
|
||||
"schema": "public",
|
||||
"name": "<name of view>"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Use cases
|
||||
---------
|
||||
|
@ -22,8 +22,8 @@ The ``config V3`` migrations files generated by the CLI are pure SQL files.
|
||||
|
||||
For ``config v2``, see :ref:`migration_file_format_v2`.
|
||||
|
||||
Migration Directory format
|
||||
-------------------------
|
||||
Migration directory format
|
||||
--------------------------
|
||||
|
||||
Each migration is stored inside a directory, which has the following structure:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user