Create a user-defined type (UDT)

Optional user-defined types (UDTs) can be created and used in table definitions. This example creates a UDT called address_type that includes a street, city, state, and zipcode. If you plan to use UDTs as a data type for columns in your table, create the UDT first.

  • graphQL command

  • Result

# create a user-defined type (UDT)
mutation createAddressUDT {
  createType(
    keyspaceName: "library"
    typeName: "address_type"
    fields: [
      { name: "street", type: { basic: TEXT } }
      { name: "city", type: { basic: TEXT } }
      { name: "state", type: { basic: TEXT } }
      { name: "zip", type: { basic: TEXT } }
    ]
  )
}
{
  "data": {
    "createType": true
  }
}