Skip to main content
Version: v2.x

Metadata API Reference: Custom Types

Introduction

Custom Types are user-defined GraphQL types which help to define Actions.

Supported from

The metadata API is supported for versions v2.0.0 and above and replaces the older schema/metadata API.

set_custom_types

set_custom_types is used to set user-defined GraphQL types. This API will replace the given types with existing ones.

POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin

{
"type": "set_custom_types",
"args": {
"scalars": [],
"enums": [],
"input_objects": [
{
"name": "User",
"fields": [
{
"name": "username",
"type": "String!"
},
{
"name": "password",
"type": "String!"
}
]
}
],
"objects": [
{
"name": "UserId",
"fields": [
{
"name": "id",
"type": "Int!"
}
],
"relationships": [
{
"name": "posts",
"type": "array",
"remote_table": "post",
"field_mapping": {
"id": "user_id"
}
}
]
}
]
}
}

Args syntax

KeyRequiredSchemaDescription
input_objectsfalseArray of InputObjectTypeSet of GraphQL Input Object
objectsfalseArray of ObjectTypeSet of GraphQL Object
scalarsfalseArray of ScalarTypeSet of GraphQL Scalar
enumsfalseArray of EnumTypeSet of GraphQL Enum