Skip to main content
Version: v2.x

Schema/Metadata API Reference: Custom Types (Deprecated)

Deprecation

In versions v2.0.0 and above, the schema/metadata API is deprecated in favour of the schema API and the metadata API.

Though for backwards compatibility, the schema/metadata APIs will continue to function.

Introduction

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

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/query 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