Metadata API Reference: Custom Types¶
Table of contents
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¶
| Key | Required | Schema | Description | 
|---|---|---|---|
| input_objects | false | Array of InputObjectType | Set of GraphQL Input Object | 
| objects | false | Array of ObjectType | Set of GraphQL Object | 
| scalars | false | Array of ScalarType | Set of GraphQL Scalar | 
| enums | false | Array of EnumType | Set of GraphQL Enum | 
