Constructor parameters for variants
Open
Nobody has claimed this yet.
enhancement
estimate-3h
low-prio
- Dominant language
- TypeScript
- Stars
- 50
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
Variants can't be initialized via the constructor and their properties must be set after the object creation. Add the same possibility to initialize variants in the constructor the same way entities do.
Assuming input schema:
type MyEntity @entity {
myData: Int!
}
type MyEntityWithVariant @entity {
myVariantValue: MyVariant!
}
type MyVariant1 @variant {
myData: Int!
}
type MyVariant2 @variant {
myData: Int!
}
union MyVariant = MyVariant1 | MyVariant2
We can currently init entities like this:
const myEntity = new MyEntity({ myData: 1 })
but variants can't be initiated like that, and properties must be set afterward:
// const myVariant1 = new MyVariant1({ myData: 1 }) // this will fail: `Expected 0 arguments, but got 1`
const myVariant1 = new MyVariant1()
myVariant1.myData = 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.