Algebraic types
One can construct complex types by defining unions of special non-entity type definitions decorated with @variant. The resulting complex type is mapped into JSON at the database level and should be prefixed with _json in when queried through the API. Here is an example
type Miserable @variant {
hates: String!
}
type HappyPoor @variant {
isMale: boolean
}
union Poor = HappyPoor | Miserable
type MiddleClass @variant {
father: Poor
mother: Poor
}
type Rich @variant {
bank: EntityC
}
union Status = Poor | MiddleClass | HappyPoor | Miserable
type Account @entity {
status: Status!
}The resulting API will support inline fragments and type resolutions:
Last updated
Was this helpful?