Metadata API Reference: Manage metadata¶
Table of contents
Introduction¶
APIs to manage Hasura metadata which is stored in hdb_catalog
schema.
replace_metadata¶
replace_metadata
is used to replace/import metadata into Hasura. Existing
metadata will be replaced with the new one.
POST /v1/query HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type" : "replace_metadata",
"version": 1 | 2
"args": <replace-metadata-args>
}
For version 1, this API corresponds to the legacy API documented under replace_metadata in the /v1/query
endpoint.
Args syntax¶
For version 2, the following structure is used:
{
allow_inconsistent_metadata: Boolean
metadata: metadata-object
}
Key | Required | Schema | Description |
---|---|---|---|
allow_inconsistent_metadata | false | Boolean | If set to true , metadata will be replaced with a warning in the response indicating which items are inconsistent (default: false ) |
metadata | true | export_metadata | The metadata that will replace the current metadata. |
If the version is not specified, then it is inferred from the format of args
.
Request¶
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type" : "replace_metadata",
"version": 2
"args": {
"allow_inconsistent_metadata": Boolean,
"metadata": <metadata-object>
}
}
Responses¶
Version 2 with inconsistencies and allow_inconsistent_metadata=false, or omitted corresponds with the response document in replace_metadata.
Version 2 example with inconsistencies and allow_inconsistent_metadata=true includes an is_consistent
and inconsistent_objects
corresponding to get_inconsistent_metadata.
HTTP/1.1 400 Bad Request
{
"internal": [
{
"type": "remote_schema",
"reason": "HTTP exception occurred while sending the request to http://localhost:5000/hello-graphql",
"definition": {
"definition": {
"url": "http://localhost:5000/hello-graphql",
"forward_client_headers": false
},
"name": "test",
"permissions": [],
"comment": "testing replace metadata with remote schemas"
}
}, ...
]
}