Metadata API Reference: Native Queries
Introduction
Track/untrack Native Queries in the Hasura GraphQL Engine.
Supported from
Native queries are supported from v2.26.0.
pg_track_native_query
pg_track_native_query
is used to add a Native Query to the GraphQL schema.
Track a Native Query as follows:
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type": "pg_track_native_query",
"args": {
"source": "default",
"root_field_name": "<name>",
"type": "query",
"arguments": {
"<name>": {
"type": "<postgres field type>",
"nullable": false | true,
"description": "<optional field description>"
}
},
"array_relationships": <Native Query relationship>,
"object_relationshps": <Native Query relationship>,
"code": "<SQL query>",
"returns": "<logical model name>"
}
}
Args syntax
Key | Required | Schema | Description |
---|---|---|---|
source | false | SourceName | Name of the source database (default: default ) |
root_field_name | true | QueryName | Name of the Native Query |
type | false | "query" | The type of the GraphQL query (currently must be "query" ) |
arguments | false | Mapping from String to NativeQueryArgument | Configuration for each argument |
code | true | String | The SQL to run on request |
returns | true | LogicalModelName | Name of the logical model representing the resulting schema |
Native Query relationships
See Native Query relationship.
pg_untrack_native_query
pg_untrack_native_query
is used to remove a Native Query from the GraphQL schema.
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type": "pg_untrack_native_query",
"args": {
"source": "default",
"root_field_name": "<name>"
}
}
Args syntax
Key | Required | Schema | Description |
---|---|---|---|
source | false | SourceName | Name of the source database (default: default ) |
root_field_name | true | QueryName | Name of the Native Query |
mssql_track_native_query
mssql_track_native_query
is used to add a Native Query to the GraphQL schema.
Track a Native Query as follows:
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type": "mssql_track_native_query",
"args": {
"source": "default",
"root_field_name": "<name>",
"type": "query",
"arguments": {
"<name>": {
"type": "<mssql field type>",
"nullable": false | true,
"description": "<optional field description>"
}
},
"array_relationships": <Native Query relationship>,
"object_relationshps": <Native Query relationship>,
"code": "<SQL query>",
"returns": "<logical model name>"
}
}
Args syntax
Key | Required | Schema | Description |
---|---|---|---|
source | false | SourceName | Name of the source database (default: default ) |
root_field_name | true | QueryName | Name of the Native Query |
type | false | "query" | The type of the GraphQL query (currently must be "query" ) |
arguments | false | Mapping from String to NativeQueryArgument | Configuration for each argument |
code | true | String | The SQL to run on request |
returns | true | LogicalModelName | Name of the logical model representing the resulting schema |
mssql_untrack_native_query
mssql_untrack_native_query
is used to remove a Native Query from the GraphQL schema.
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type": "mssql_untrack_native_query",
"args": {
"source": "default",
"root_field_name": "<name>"
}
}
Args syntax
Key | Required | Schema | Description |
---|---|---|---|
source | false | SourceName | Name of the source database (default: default ) |
root_field_name | true | QueryName | Name of the Native Query |
bigquery_track_native_query
bigquery_track_native_query
is used to add a Native Query to the GraphQL schema.
Track a Native Query as follows:
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type": "bigquery_track_native_query",
"args": {
"source": "default",
"root_field_name": "<name>",
"type": "query",
"arguments": {
"<name>": {
"type": "<bigquery field type>",
"nullable": false | true,
"description": "<optional field description>"
}
},
"array_relationships": <Native Query relationship>,
"object_relationshps": <Native Query relationship>,
"code": "<SQL query>",
"returns": "<logical model name>"
}
}
Args syntax
Key | Required | Schema | Description |
---|---|---|---|
source | false | SourceName | Name of the source database (default: default ) |
root_field_name | true | QueryName | Name of the Native Query |
type | false | "query" | The type of the GraphQL query (currently must be "query" ) |
arguments | false | Mapping from String to NativeQueryArgument | Configuration for each argument |
code | true | String | The SQL to run on request |
returns | true | LogicalModelName | Name of the logical model representing the resulting schema |
bigquery_untrack_native_query
bigquery_untrack_native_query
is used to remove a Native Query from the GraphQL schema.
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type": "bigquery_untrack_native_query",
"args": {
"source": "default",
"root_field_name": "<name>"
}
}
Args syntax
Key | Required | Schema | Description |
---|---|---|---|
source | false | SourceName | Name of the source database (default: default ) |
root_field_name | true | QueryName | Name of the Native Query |