-
Notifications
You must be signed in to change notification settings - Fork 2k
add test to ensure defer/stream payloads are always sent in correct order #3165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Support returning async iterables from resolver functions
# Conflicts: # src/index.d.ts # src/type/directives.d.ts # src/type/directives.ts # src/type/index.js
# Conflicts: # src/index.d.ts # src/type/directives.d.ts # src/type/directives.ts # src/type/index.js
# Conflicts: # src/execution/execute.ts # src/validation/index.d.ts # src/validation/index.ts
# Conflicts: # src/subscription/subscribe.ts
…phql#2843) # Conflicts: # src/execution/execute.ts
* fix(race): concurrent next calls * refactor test * use invariant * disable eslint error * fix
Now passing, with some changes in payload order, and in execution algorithm, namely completion does not start for any streamed item until completion for the prior item finishes. This is suboptimal. What we want is for completion to start for all possible items as soon as possible, but for payload order to still be preserved. Or -- perhaps, we want to relax the requirement in the spec for all items to be sent in sequential order? |
Note that the failing check has to do with uploading code-coverage and appears--at least to me--to be orthogonal to the changes here. |
see discussion at #2848 (which perhaps should be moved here?) I have reverted the "fix" for now as I am not sure it is the desirable behavior. Perhaps we should "fix" the tests to reflect the current implementation. |
for list fields that return a list of promises rather than an asyncIterable
I added additional tests for stream payloads that are asyncIterables, defer payloads, and defer/stream payload interactions, as I understood from recent WG notes that we want to enforce order for both defer/stream payloads by default, and occurred to me that this "bug" may be more far-reaching, include defer fragments, etc. Personally, I am agnostic to what the desired behavior should be, at this point tending more toward @robrichard that we should just send what we have, when we have it. Although I am sensitive to @benjie 's point about malicious servers, I think that we can push onto clients to handle that situation less naively. |
I would like to caution against pushing requirements onto the client without sufficiently evaluating the alternatives, primarily because there's a lot more GraphQL clients than there are GraphQL servers (e.g. there's a bunch that people roll their own using e.g. |
I agree there is validity to architecting toward the simplest possible behavior in the hopes of not being blamed then things go “wrong.” But I also think we should be thinking primarily about use cases. Might it make sense to display data from a deferred User Profile fragment when it’s ready even when the complete User fragment higher up in the tree has not yet come in? I think that would really be the clients choice. Would it make sense to give client data from a later list item as soon as available, “leaking” as well the knowledge that they are X intervening items? I think it would. I am envisioning basically the overarching goal of incremental delivery being to provide overall speediest delivery. GraphQL lists always have a defacto order when resolved and so they can be thought of as a map with numeric keys. Overall agree with argument approach to dictate this, but I feel like the default behavior should be to optimize for fastest delivery, not for easiest client implementation. But I wouldn’t put my own preference on a pedestal. I will be working on an stitching implementation that will eventually probably have to handle both, whether by default or by argument, so I probably have to just start out not making assumptions about the order… |
c98de06
to
a09e09c
Compare
4ca771c
to
dca7ad4
Compare
3dd7030
to
266a563
Compare
2cb1dad
to
fb1b2aa
Compare
7eb1eb2
to
30f0cc5
Compare
f886827
to
215cada
Compare
Closed as fixed here and in graphql-executor |
currently failing @robrichard @brainkim