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.

Merging subtrees in cache

See original GitHub issue

I’ve got two queries with overlapping subtrees (shown below). In the editorsQuery, the id of the currentVersion might be different than in the documentQuery, because someone might have updated the document in the time between the first and the second query. If that happens, Apollo seems to return an empty object wherever the documentQuery is used. If I inspect the cache in the Apollo devtools, the second query overwrites the currentVersion completely, leaving out the downloadUrl because it’s not included in the editorsQuery. Is there a way to instead merge the two results? The queries used in this example are of course fictional, but we have many of these types of queries in our application.

query documentQuery {
  document {
    id
    currentVersion {
      id
      downloadUrl 
    }
  }
}
query editorsQuery {
  document {
    id
    currentVersion {
      id
      editors {
        id
        name
      }
    }
  }
}

I’ve made a reproduction of this issue on CodeSandbox:

Front-end: https://codesandbox.io/s/k0wm12zpqr API: https://codesandbox.io/s/k282yz01p7

Make sure to open the CodeSandbox for the API because the server may have shut down in the meantime. You might have to refresh the front-end until the API is back up 😃

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
RyannGaleacommented, Mar 8, 2020

I am having issues where other queries are overwriting previous queries and nullifying data that should just be merged. Not sure how to resolve it.

0reactions
hwillsoncommented, Apr 27, 2021

A lot of the Apollo Client internals have changed since v3 was launched. We recommend trying a more modern version of @apollo/client. Let us know if you’re still encountering this issue. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mastering Git subtrees - Medium
It's actually pretty easy; we just need to update our local cache from the subtree's remote, then do a subtree merge (using a...
Read more >
git subtree cache exists - Stack Overflow
You need to clear the subtree cache by removing the .git/subtree-cache folder. You could always try seaching for the ...
Read more >
Subtree - GitLab Docs
Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.
Read more >
git-subtree.sh - Apple Open Source
... 'merge', and 'pull' squash merge subtree changes as a single commit " eval ... cache_setup() { cachedir="$GIT_DIR/subtree-cache/$$" rm -rf "$cachedir" ...
Read more >
Git Subtree merged into mainline git - Hacker News
If you want to know what the git subtree command is, ... instead of the source (basically creating a caching layer under your...
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