Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor parameters for variants #461

Open
ondratra opened this issue Sep 29, 2021 · 0 comments
Open

Constructor parameters for variants #461

ondratra opened this issue Sep 29, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request estimate-3h 3h task low-prio

Comments

@ondratra
Copy link
Contributor

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
@ondratra ondratra added enhancement New feature or request estimate-3h 3h task labels Sep 29, 2021
@ondratra ondratra self-assigned this Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request estimate-3h 3h task low-prio
Projects
None yet
Development

No branches or pull requests

3 participants