Joystream / Joystream/hydra

Constructor parameters for variants

Open
#461 0 comments 0 reactions 1 assignee View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.