useQuery data object not updating with cache


Found the answer. If I set resultCaching to false in the client options the object is recognized to be new and the data updates…

Like the title says, I am using useQuery to return a data object, but when the cache updates, the data object does not! It’s also not updating when the query is sent as a network request. The initial query returns an accurate data object, but if I do a mutation then unmount → remount the component, a network request is made that returns the correct data, but the data object is never updated! This also happens when I set the fetchPolicy to “network-only”.

If I remove the cache options from the ApolloClient constructor, effectively removing the cache from the equation, the data object is now updated properly.
Passing refetchQueries to the mutation function results in data updating properly.

The mutated data is nested, so I feel like maybe there is some kind of comparison going on that’s stopping the update. If I also update an immediate child field to test it, data does update… but the nested values are still stale!

I’ve also tried setting returnPartialData: true. Nothing.

Any idea of what I’m doing wrong?

The query is something like this:

cart {
    product {
        sizes {

The mutation will update the quantity of one of the sizes, then update the cache with the response. The cache is correct, and the useQuery will use the cache on subsequent component mounts (and have the correct data as long as I didn’t mutate in the meantime).

Also, if I run the query in the devtools with the cache enabled it works fine. Since data is not updating with a network response either, I am fairly confident the problem is not the cache/configuration of the cache itself, but rather the behaviour of how data is “watched”/updated when the cache is enabled (even when the query is sent to the server). I say this because the queries to the server would update the object properly when I didn’t configure the cache.