Skip to content
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

Add DedupInterceptor #3760

Closed
martinbonnin opened this issue Dec 30, 2021 · 2 comments
Closed

Add DedupInterceptor #3760

martinbonnin opened this issue Dec 30, 2021 · 2 comments

Comments

@martinbonnin
Copy link
Contributor

In cases where the same query is executed twice in a short period of time, add an opt-in way to deduplicate the query. For an example, given the below scenario

// prefetch when initializing the app
apolloClient.query(myQuery).fetchPolicy(CacheFirst).execute()

// the main screen requests the data when the app starts
apolloClient.query(myQuery).execute()

It'd be nice to avoid the extra network roundtrip if the two request come at the same time. This could be done with an interceptor that "remembers" the requests in flight and avoids a round trip if one is already pending.

Open question: Do we want to potentially dedup cache reads as well. At first sight, it looks more complicated but maybe it's only a matter of inserting the interceptor before/after the cache interceptor.

@ynkm169
Copy link

ynkm169 commented Jan 4, 2023

Do we want to potentially dedup cache reads as well

It depends on which is more costly? Thread contention or dedup logic?
There is some cost to accessing the cache #4605

@BoD
Copy link
Contributor

BoD commented Jun 14, 2024

Closing for now as this didn't seem to get much traction - please re-open if you'd like to see this implemented.

@BoD BoD closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants