question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cache merge is producing extra network call

See original GitHub issue

Intended outcome:

Given two components, Component A and Component B that run the same query, with Component B requesting a little more from the graph.

When defining a custom merge function and using network-only on both components useQuery calls.

There should only be 2 network requests made. 1 for Component A and 1 for B.

Screenshot 2020-09-17 at 14 46 45

Actual outcome: The request for Component A is made again after component B finishes.

How to reproduce the issue: Using apollo client v3.2.0 https://codesandbox.io/s/awesome-gagarin-4rdyp?file=/src/App.js

Not happening using apollo client v2 https://codesandbox.io/s/nice-goodall-odfcy?file=/src/App.js

Versions @apollo/client@3.2.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dskelton-r7commented, Sep 18, 2020

@benjamn I also just noticed this issue that seems similar in nature https://github.com/apollographql/apollo-client/issues/6307 So I downgraded to @apollo/client@3.0.0-beta.45 and its not longer happening. Here is a reproduction of that.

Only 2 requests are being made here https://codesandbox.io/s/infallible-gagarin-u32cz?file=/src/App.js

0reactions
hwillsoncommented, May 11, 2021

Let us know if this is still a concern with @apollo/client@latest - thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customizing the behavior of cached fields - Apollo GraphQL
The merge function. If you define a merge function for a field, the cache calls that function whenever the field is about to...
Read more >
Apollo GraphQL merge cached data - Stack Overflow
On the first request, I set Movie data in the cache, on the second request to the same query I just replace old...
Read more >
Customizing the behavior of cached fields - Client (React)
If you define a merge function for a field, the cache calls that function whenever the field is about to be written with...
Read more >
Caching in GitLab CI/CD
A cache is one or more files a job downloads and saves. Subsequent jobs that use the same cache ... However, the first...
Read more >
Merge geometry caches - Maya - Autodesk Knowledge Network
If the caches you want to merge aren't overlapping, but have gaps between them, then the gaps are linearly interpolated and no cache...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found