Replies: 5 comments 9 replies
-
@benjie am I understanding correctly that this is about the order which the payloads from these deferred fragments are returned? The prior discussion on this is here: #17. I think this case is similar to example B in the linked discussion. In both of your examples, all of the deferred fragments should begin their execution when the recursive Looking again, my graphql-js pr implements this correctly (unit test), but I don't think it is defined correctly in the spec. I'll update the spec PR to make sure this is clear. |
Beta Was this translation helpful? Give feedback.
-
@mjmahone can you speak to this based on your experience at Meta? It seems to me like it would be easy to create nested defers from Relays fragment composition |
Beta Was this translation helpful? Give feedback.
-
I think this issue was wrongly decided. Although I agree with @benjie that there is potential an attack vector with multiple deferred fragments, but I am not sure that the problem is exacerbated too much with honoring nesting versus flattening. Nesting does imply that the spread fragments have to respect a certain order, i.e. that there is a second level of "please deliver these fields with respect to other fields" going on. More formally: nested |
Beta Was this translation helpful? Give feedback.
-
Based on live discussion today, I'm also a little concerned. But not sure which is the right call. One thing to specifically consider is that in larger codebases fragment references can sprawl out across many files. Local applications of defer may find themselves within nested other applications of defer. That means sometimes nested defer are intentional statements of phasing, others are accidents of composition of modular fragments |
Beta Was this translation helpful? Give feedback.
-
This has been addressed by the new response format described in #69 Deferred fields are no longer duplicated in this response format |
Beta Was this translation helpful? Give feedback.
-
If you had this operation:
Am I right in thinking that nothing special prevents this? I.e. you'd end up with:
i.e. three nested (chained) deferred payloads from a single field.
I think we have to allow this (due to fragment isolation) but also... it does feel like another attack vector. I guess a server is free to obey the first defer and ignore the others, resulting in a deferred list of
id, name, avatarUrl, bio
.Whilst pondering this, I was wondering if we could/should instead do flattening and make this equivalent to:
One advantage of this approach is the deferreds are no longer chained; but a disadvantage is that we can't do the solution I suggested above whereby we honour the top one only and yet still result in all fields being deferred.
If you've had discussions about this previously, I'd love to read through them - could you point me to them? I'm somewhat tempted in my own servers to limit the number of defers in the document, or potentially to always disobey nested stream/defers.
Beta Was this translation helpful? Give feedback.
All reactions