-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allows for subscriptions to be de-duped #6910
Conversation
@jkossis: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
We also could do something similar to here (where it is omitted) apollo-client/src/core/QueryManager.ts Lines 771 to 775 in e440b49
getObservableFromLink 's default assignment.
|
@benjamn what are your thoughts? I saw your comments here (apollographql/apollo-feature-requests#74), and it seemed like you were in favor of this behavior. Interested in your input. |
@jkossis I would have thought this should already work (unless there's a more general problem), since we are passing deduplication: boolean =
// Prefer context.queryDeduplication if specified.
context?.queryDeduplication ??
this.queryDeduplication, That said, I can totally imagine there being issues with deduplicating subscriptions, since they last a lot longer than queries, and have more results, so I'm interested to hear what kind of (mis)behavior you're seeing. |
@benjamn I agree, the context is already being looked at in IMO, the most flexible solution may be omitting that 4th parameter when calling In terms of misbehavior, I think the de-duping may have less issues than anticipated. The logic would be if an identical subscription is active, don't create a new one. And I think this may already work correctly as is. But you are significantly more familiar with the code, so I lean on you. |
@benjamn thoughts on above? I think the best solution is not passing the 4th parameter to |
@hwillson any thoughts as well? Seems like this could be a nice performance gain essentially for free. |
Is there anything I can do to help this PR get merged in? |
any chance we'll be able to get de-duplicated subscriptions? this would really improve performance it just needs a really small change to allow this option to be left up to the user rather than how it is right now, forced to be false |
would really love for this to be merged in as well |
again happy to provide assistance in any form. what is keeping this change from being merged in? |
Just waiting on someone with write access to merge this in. Seems to be an easy fix, that is backwards-compatible. |
@jkossis Has anyone with write access so far been involved in this thread? If not: |
@ntziolis I believe @benjamn has write access. In terms of configuration, this change actually allows for greater configuration, leveraging the assignment here: apollo-client/src/core/QueryManager.ts Line 774 in 3d3e77b
Right now, false is being passed explicitly, so you can't configure it on the request's context, or at the global level ( |
I see. I would have thought this global level config might have been an issue since it will effect existing users, but after following the linked threads it seems that the apollo team is ok with this behavior change as you pointed out. Thank you for pushing this forward. @benjamn @hwillson Is there anything keeping the apollo team from getting this merged in? |
Is there anything blocking this? It's a one line change that saves a ton of network traffic and unnecessary overhead. |
It would be great if this could be fixed! I never changed my code, because I hoped this would be merged in soon. Will this still be fixed, or should I make some workaround? Thanks for all the great work with Apollo! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the updates/reasoning here since I last looked at this issue make sense to me! Thanks for continuing to work on this @jkossis.
@jkossis @floriaanpost @ntziolis @carlosdp @rapacity These changes are now available in |
I take it this PR solves the question I raised in discussion #7360? |
Allows for the consumer of the subscription to specify whether there should be de-duplication or not. This keeps the backwards compatible behavior of
false
, so it shouldn't introduce any kind of breaking behavior.