Same stream across deferred fragments #100
Replies: 4 comments
-
See the YouTube recording to understand this... query {
nestedObject {
nestedFriendList @stream(initialCount: 0) {
Part1: __typename
id
}
}
nestedObject {
... @defer {
Part2: __typename
nestedFriendList @stream(initialCount: 0) {
Part3: __typename
id
name
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
{
nestedObject {
nestedFriendList {
...@defer {
something {
id
}
}
}
}
nestedObject {
... @defer {
nestedFriendList {
...@defer {
something {
id
name
}
}
}
}
}
} should be equivalent to: {
nestedObject {
nestedFriendList {
...@defer {
something {
id
}
}
}
}
nestedObject {
... { # no defer here
nestedFriendList {
...@defer {
something {
id
name
}
}
}
}
}
} which should be equivalent to: should be equivalent to: {
nestedObject {
nestedFriendList {
...@defer {
something {
id
}
}
...@defer {
something {
id
name
}
}
}
}
} I think the same should be true for |
Beta Was this translation helpful? Give feedback.
-
query {
nestedObject {
nestedFriendList @stream(initialCount: 0) {
id
slow1
}
}
nestedObject {
... @defer {
nestedFriendList @stream(initialCount: 0) {
id
slow2
}
}
}
} [
{
data: {
nestedObject: {
nestedFriendList: [],
},
},
pending: [
{ id: '0', path: ['nestedObject', 'nestedFriendList'] },
{ id: '1', path: ['nestedObject', 'nestedFriendList'] },
],
hasNext: true,
},
{
incremental: [
{
items: [{ id: ' 1' }],
id: '0',
},
{
items: [{ slow1: 'slow1' }],
id: '0',
},
{
items: [{ slow2: 'slow2' }],
id: '1',
},
],
hasNext: true,
},
{
completed: [{ id: '0' }],
hasNext: false,
},
]
|
Beta Was this translation helpful? Give feedback.
-
@Keweiqu @mjmahone We're considering adding validation to prevent |
Beta Was this translation helpful? Give feedback.
-
Context
Currently we have validation in
OverlappingFieldsCanMerge
rule that prevents@stream
from being placed on the same field with different arguments. If this is desired, the user can alias one of the fields which will produce two independent streams.What happens if you have the same field with
@stream
, with the same arguments, both inside and out of a deferred fragment, or in two different deferred fragments?Example 1:
This was discussed in the Jan 2025 defer-stream-wg meeting.
Thinking through the use case of a developer using a framework that associates UI components with fragments, we can rewrite the above to:
The following options were ruled out:
@stream
is used in adjacent components.name
field to be delivered separately from theid
field, and could potentially allow us to relax the validation in OverlappingFieldsCanMerge.pending
andcompleted
results in the response to account for new fields on a streamAfter further discussion, it may not be desirable to have stream on different instances of the same field at all even without wrapping
@defer
. Given the following query:A user adding
verySlowField
may be unintentionally be affecting the performance of a separate component relying on the first instance of themyList
field.Decision
The WG decided to propose expanding
OverlappingFieldsCanMerge
to prevent merging of any instances of@stream
on the same field based on the following guiding principles:Additionally
Beta Was this translation helpful? Give feedback.
All reactions