Replies: 1 comment 6 replies
-
Keep it simple; just do what the user would expect: siblings are independent, children are dependent. We can add a priority system later if it turns out to be a need (I strongly doubt it will). query GenericExample {
me {
fastField
... @defer(label: "OuterA") { intermediateFieldA ... @defer(label: "InnerA") { slowFieldA } }
... @defer(label: "OuterB") { intermediateFieldB ... @defer(label: "InnerB") { slowFieldB } }
}
}
I am still of the belief that one level of |
Beta Was this translation helpful? Give feedback.
-
In #80, we decided that nested defers, even at the same level, should always be delivered "in order," from the outermost defer to the innermost. What if there are multiple sibling nested defers? Should all of the outermost defers be delivered before any of the innermost?
For example:
Once
intermediateFieldA
is completed,OuterA
can be delivered. At that point, canslowFieldA
begin executing (assuming no early execution) and be delivered, if it chances to complete beforeintermediateB
?Crucially, as mentioned in the early execution discussion,
slowFieldA
may in fact interfere with or delay execution of intermediateFieldB, so one might argue for the delivery of all singly-deferred fragments as an initial "stage," followed by all doubly deferred fragments in the next "stage," etc.On the other hand, consider the following example:
In a fragment-oriented component-based approach, the developer of the SemiCriticalUserDetails component may attempt to use
@defer
to speed up initial rendering of their component, without knowing that their component was being deferred at all, let alone that the use of@defer
within their component may cause the deferred fields in their critical component to have to wait for all other singly deferred components to complete.The problem is that although the degree of nesting tells us the priority of a fragment with respect to the fragment's branch, we cannot assume at all that the degree of nesting corresponds to the fragment's priority across branches.
Looking forward, a
by
argument for the@defer
argument can potentially be used (at a later stage, as a feature enhancement) to add some specificity and allow comparison across branches. (Perhaps apriority
argument could alternatively be used to assign an absolute priority, but the idea is similar.) The above example could be rewritten something like this:This would require best practices as to
deferBy
intervals within an organization, but seems like a feasible path forward.Presumably, without the use of this argument, ie in the initial example, a constant default of some number would be used, and so we would get the staged approach.
Another question is how this interacts with a stream being run in parallel to a few nested defers? How many streaming elements should we allow to run before running a nested defer? Should we make no assumptions in this regard at all?
Open for discussion!
Beta Was this translation helpful? Give feedback.
All reactions