Skip to main content
Version: v2.x

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​

KeyRequiredSchemaDescription
sourcefalseSourceNameName of the source database (default: default)
root_field_nametrueQueryNameName of the Native Query
typefalse"query"The type of the GraphQL query (currently must be "query")
argumentsfalseMapping from String to NativeQueryArgumentConfiguration for each argument
codetrueStringThe SQL to run on request
returnstrueLogicalModelNameName 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​

KeyRequiredSchemaDescription
sourcefalseSourceNameName of the source database (default: default)
root_field_nametrueQueryNameName 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​

KeyRequiredSchemaDescription
sourcefalseSourceNameName of the source database (default: default)
root_field_nametrueQueryNameName of the Native Query
typefalse"query"The type of the GraphQL query (currently must be "query")
argumentsfalseMapping from String to NativeQueryArgumentConfiguration for each argument
codetrueStringThe SQL to run on request
returnstrueLogicalModelNameName 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​

KeyRequiredSchemaDescription
sourcefalseSourceNameName of the source database (default: default)
root_field_nametrueQueryNameName 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​

KeyRequiredSchemaDescription
sourcefalseSourceNameName of the source database (default: default)
root_field_nametrueQueryNameName of the Native Query
typefalse"query"The type of the GraphQL query (currently must be "query")
argumentsfalseMapping from String to NativeQueryArgumentConfiguration for each argument
codetrueStringThe SQL to run on request
returnstrueLogicalModelNameName 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​

KeyRequiredSchemaDescription
sourcefalseSourceNameName of the source database (default: default)
root_field_nametrueQueryNameName of the Native Query