Create a user-defined type (UDT)
User-defined types (UDTs) can be created as GraphQL object types.
UDTs are optional, but if you wish to use a UDT in another object type definition,
you’ll want to create the UDT first.
Once created, you can include the type in the schema deployed via the GraphQL playground.
Here are two examples that create a UDT called Address
that includes a street, city, state, and zipcode,
and a UDT called Review
that includes a book title, comment, rating and review data.
type Address @cql_entity(target: UDT) @cql_input { (1)
street: String
city: String
state: String
zipCode: String @cql_column(name: "zip_code")
}
type Review @cql_entity(target: UDT) @cql_input {
bookTitle: String @cql_column(name: "book_title")
comment: String
rating: Int
reviewDate: Date @cql_column(name: "review_date")
}
Directives in example:
1 | The @cql_entity(target: UDT) denotes that the type is stored as a user-defined type (UDT)
in the underlying database table. |