-
Notifications
You must be signed in to change notification settings - Fork 271
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
eager hasNext: false
in @defer
payloads
#1687
Comments
Thanks for opening this. There might be times when the router has to do this. I'm not sure if this is one of them. |
For some context, on the Kotlin Client side this is causing an extra emission so the user sees 3 updates at the moment (with the same values for 2 and 3). I'm trying to figure out if this is something that should be filtered client side or not (this might not be trivial to do as we have code that relies on |
@martinbonnin 👋 thanks for pointing this out! We discussed this particular problem in our Web Client planning session today and @alessbell did some work on the client side to handle this case, so she was going to share some thoughts later. |
For some more Context, Apollo Kotlin merges all payloads so that what's emitted to the user is always the same (strongly typed) class. For and example, with a query like below: {
fast
...deferedFragment @defer
}
fragment derferedFragment on Query {
slow
} the user is going to see something like this (details omitted): payload 1: Query.Data(
fast = 42,
deferedFragment = null
) payload 2: Query.Data(
fast = 42,
deferedFragment = DeferredFragment(
slow = 0
)
) payload 3 (identical to payload 2): Query.Data(
fast = 42,
deferedFragment = DeferredFragment(
slow = 0
)
) The user can debounce this with All in all, having the
We might have to handle it no matter what so I opened this issue to get some feedback about it but if the answer is that it's not possible, we'll find ways to support it. |
@martinbonnin to confirm: if we couldn't resolve this issue, and released with this as is, would we need to bring into scope this issue for the Kotlin client to resolve before the release so a user could use I agree, that
|
I think it's fine to release as-is and let users debounce for now. Functionality is still there. It's just sub-optimal. Users can still call
Mostly yes. What I mean by "eager" is send the |
Signed-off-by: Benjamin Coenen <[email protected]>
Signed-off-by: Benjamin Coenen <[email protected]>
@martinbonnin sounds good, I agree it shouldn't block our release. To your point about:
Can we ensure we update the documentation you've provided, it might be nice to be more explicit about this case. |
FYI I have a wip branch with a fix that seems good enough. I think I will be able to finalize it this week. |
) close #1687 Signed-off-by: Benjamin Coenen <[email protected]>
a heads up on this: the fix in #1736 is not enough, because with parallel deferred responses (like I am looking for a different solution in #1745 but it is not working right now, and it is still a bit of a hack. There is no way to correctly predict how many deferred responses there will be from inside query plan execution, except by synchronization, which could be disastrous for performance, so if we do not find a solution, the last empty response will come back as that's the only correct one for now. @martinbonnin is there a way to change the kotlin client to be more flexible here? There is no guarantee that all defer implementations will do what it expects |
we previously returned an empty graphql response at the end of the response stream to set the `hasNext` field to false, to indicate that no more responses will come. That empty response is causing issues in some clients, so 24a00e6 was a fix to set the `hasNext` on a deferred response from inside query planner execution, but it does not account for parallel deferred response executions, so one response might come with `hasNext` to false then get another one. This commit uses another approach, where we go through an intermediate task that checks if the response stream is closed. Fixes #1687
Using router at 6b83a74 and this
@defer
query:I'm getting these payloads:
I believe this is compliant but it's still introducing latency because the client doesn't close the flow until the
hasNext: false
is received. It would be nice to have thehasNext: false
eagerly:The text was updated successfully, but these errors were encountered: