Allw enum in stream indexes
Problem to solve and solution
Enums are currently not allowed in keys. But they would be useful in a schema like:
type Price @schema @key(fields: ["exchange", "asset", "day"]) {
exchange: Exchange!
asset: String!
day: Timestamp!
price: Float!
}
enum Exchange {
A
B
C
}
Proposed solution and changes
- See
pkg/schema/compiler.go#checkIndex
- Make sure
pkg/codec/codec.go#MarshalKey,UnmarshalKey
can handle the enum representation (are they represented as ints or strings?)
Risks and challenges
- As enums are editable, make sure that can't have adverse effects
Edited by Benjamin Egelund-Müller