Schema/Metadata API Reference: Custom Types¶
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¶
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 |
InputObjectType¶
A simple JSON object to define GraphQL Input Object
Key | Required | Schema | Description |
---|---|---|---|
name | true | GraphQLName | Name of the Input object type |
description | false | String | Description of the Input object type |
fields | true | Array of InputObjectField | Fields of the Input object type |
InputObjectField¶
Key | Required | Schema | Description |
---|---|---|---|
name | true | GraphQLName | Name of the Input object field |
description | false | String | Description of the Input object field |
type | true | GraphQLType | GraphQL ype of the input object field |
ObjectType¶
A simple JSON object to define GraphQL Object
Key | Required | Schema | Description |
---|---|---|---|
name | true | GraphQLName | Name of the Object type |
description | false | String | Description of the Object type |
fields | true | Array of ObjectField | Fields of the Object type |
relationships | false | Array of ObjectRelationship | Relationships of the Object type to tables |
ObjectField¶
Key | Required | Schema | Description |
---|---|---|---|
name | true | GraphQLName | Name of the Input object field |
description | false | String | Description of the Input object field |
type | true | GraphQLType | GraphQL type of the input object field |
ObjectRelationship¶
Key | Required | Schema | Description |
---|---|---|---|
name | true | RelationshipName | Name of the relationship, shouldn’t conflict with existing field names |
type | true | [ object | array ] |
Type of the relationship |
remote_table | true | TableName | The table to which relationship is defined |
field_mapping | true | Object (ObjectField name : Remote table’s PGColumn) | Mapping of fields of object type to columns of remote table |
ScalarType¶
A simple JSON object to define GraphQL Scalar
Key | Required | Schema | Description |
---|---|---|---|
name | true | GraphQLName | Name of the Scalar type |
description | false | String | Description of the Scalar type |
EnumType¶
A simple JSON object to define GraphQL Enum
Key | Required | Schema | Description |
---|---|---|---|
name | true | GraphQLName | Name of the Enum type |
description | false | String | Description of the Enum type |
values | true | Array of EnumValue | Values of the Enum type |
EnumValue¶
Key | Required | Schema | Description |
---|---|---|---|
value | true | GraphQLName | Value of the Enum type |
description | false | String | Description of the value |
is_deprecated | false | Boolean | If set to true , the enum value is marked as deprecated |
Was this page helpful?
Thank you for your feedback!
Stay up to date with product & security news
See past editions