Metadata API Reference: Databases (v2.0 and above)¶
Table of contents
Introduction¶
Add/remove databases in Hasura GraphQL engine.
Supported from
The metadata API is supported for versions v2.0.0
and above and replaces the older
schema/metadata API.
pg_add_source¶
pg_add_source
is used to connect a Postgres database to Hasura.
Add a database with name pg1
:
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type": "pg_add_source",
"args": {
"name": "pg1",
"configuration": {
"connection_info": {
"database_url": {
"from_env": "<DB_URL_ENV_VAR>"
},
"pool_settings": {
"max_connections": 50,
"idle_timeout": 180,
"retries": 1
}
}
}
}
}
Args syntax¶
Key | Required | Schema | Description |
---|---|---|---|
name | true | SourceName | Name of the Postgres database |
configuration | true | PGConfiguration | Database connection configuration |
pg_drop_source¶
pg_drop_source
is used to remove a Postgres database from Hasura.
Remove a database with name pg1
:
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
"type": "pg_drop_source",
"args": {
"name": "pg1"
}
}
Args syntax¶
Key | Required | Schema | Description |
---|---|---|---|
name | true | SourceName | Name of the Postgres database |
Was this page helpful?
Thank you for your feedback!