Nested defer and order of payloads #26
-
Hi! Let's say for instance we have this schema: type Query {
computer: Computer!
}
type Computer {
cpu: String!
year: Int!
screen: Screen!
}
type Screen {
resolution: String!
isColor: Boolean!
} And this query: query Screen {
computer {
__typename
cpu
... on Computer @defer {
year
screen {
__typename
resolution
... on Screen @defer {
isColor
}
}
}
}
} It looks like the response could be: Payload 1{
"data": {
"computer": {
"__typename": "Computer",
"cpu": "386"
}
},
"hasNext": true
} Payload 2{
"data": {
"isColor": true
},
"path": [
"computer",
"screen"
],
"hasNext": true
} Payload 3{
"data": {
"year": 1993,
"screen": {
"__typename": "Screen",
"resolution": "640x480"
}
},
"path": [
"computer"
],
"hasNext": false
} Here a value for My question is: should this really be allowed, or should the spec indicate that payloads should be emitted in a "hierarchical" order for nested cases like this one? More contextGiven this schema and query, here's what our (currently non
One simple evolution to make this
But this approach doesn't really work if we can receive fields of |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@BoD we have a discussion topic for this: #17 The latest code on the defer-stream branch will ensure the payloads are sent in the order you are expecting. This hasn't been published to npm yet. |
Beta Was this translation helpful? Give feedback.
-
Thank you, that is great news! 👍 (And sorry I didn't see it was already addressed). I actually have a follow-up question but I'll add it there - I'll close this one. |
Beta Was this translation helpful? Give feedback.
@BoD we have a discussion topic for this: #17
The latest code on the defer-stream branch will ensure the payloads are sent in the order you are expecting. This hasn't been published to npm yet.