Deeply nested variants
Open
@metmirr is already working on this.
Since May 28, 2021.
estimate-12h
high-prio
highest-prio-feature
hydra-cli
qn-hydra-board
- Dominant language
- TypeScript
- Stars
- 50
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
Moved from: https://github.com/Joystream/joystream/pull/2345#issuecomment-838429476
Deeply nested variant types
There seems to be an issue with querying deeply nested varaint types, let's assume we have a following schema:
type ApplicationStatusPending @variant {
# No additional information needed
_phantom: Int
}
type ApplicationStatusAccepted @variant {
"Related OpeningFilled event"
openingFilledEvent: OpeningFilledEvent!
}
type ApplicationStatusRejected @variant {
"Related OpeningFilled event"
openingFilledEvent: OpeningFilledEvent!
}
type ApplicationStatusCancelled @variant {
"Related OpeningCanceled event"
openingCanceledEvent: OpeningCanceledEvent!
}
type ApplicationStatusWithdrawn @variant {
"Related ApplicationWithdrawn event"
applicationWithdrawnEvent: ApplicationWithdrawnEvent!
}
union WorkingGroupApplicationStatus =
ApplicationStatusPending
| ApplicationStatusAccepted
| ApplicationStatusRejected
| ApplicationStatusWithdrawn
| ApplicationStatusCancelled
type WorkingGroupApplication @entity {
"Application id ({workingGroupName}-{applicationId})"
id: ID!
"Related working group opening"
opening: WorkingGroupOpening!
"Current application status"
status: WorkingGroupApplicationStatus!
# ...
type WorkingGroupOpening @entity {
"Opening id ({workingGroupName}-{openingId})"
id: ID!
"List of opening applications"
applications: [WorkingGroupApplication!] @derivedFrom(field: "opening")
# ...
}
When I'm executing the following query:
query {
workingGroupApplications {
id
opening {
id
}
status {
__typename
...on ApplicationStatusAccepted {
openingFilledEvent {
id
}
}
}
}
}
I'm getting some results like:
{
"data": {
"workingGroupApplications": [
{
"id": "contentDirectoryWorkingGroup-0",
"opening": {
"id": "contentDirectoryWorkingGroup-0"
},
"status": {
"__typename": "ApplicationStatusAccepted",
"openingFilledEvent": {
"id": "-69-UePHPb"
}
}
},
# ...
But if I add one more level of nesting, by querying applications in a specific opening:
query {
workingGroupOpeningByUniqueInput(where: { id: "contentDirectoryWorkingGroup-0" }) {
applications {
id
opening {
id
}
status {
__typename
...on ApplicationStatusAccepted {
openingFilledEvent {
id
}
}
}
}
}
}
I get:
{
"data": {
"workingGroupOpeningByUniqueInput": {
"applications": [
{
"id": "contentDirectoryWorkingGroup-0",
"opening": {
"id": "contentDirectoryWorkingGroup-0"
},
"status": {
"__typename": "ApplicationStatusAccepted",
"openingFilledEvent": null
}
}
]
}
}
}
Notice the openingFilledEvent is null in this case
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.