You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can receive this SimpleUser object from multiple different queries, and each time we receive it, it can contain a different array of Book and SomeObject, which results in the newest received SimpleUser overwriting the previous one. Is there an easy way for me to merge the new and old arrays every time we receive a SimpleUser regardless of which query it comes from?
Thank you!
The text was updated successfully, but these errors were encountered:
One way is to use the ApolloStore API to manually store a SimpleUser that is a combination of the one existing in the cache, and the one you just received from the network. You'd have to do that at all the places that execute queries that return SimpleUser.
There are also incubating (experimental) APIs that allow to pass the desired merge algorithm, which will be called whenever an object needs to be merged. These exist to help with pagination scenarios but If you are willing to try experimental APIs I believe they could also be used for your use-case.
Both approaches are described in this document. Hope this helps!
Thank you for your reply! And sorry for the slow follow up.
I'm trying to implement the second approach you listed above. However I'm running into this issue
Duplicate class com.apollographql.apollo3.cache.normalized.ApolloStore found in modules apollo-normalized-cache-incubating-jvm-4.0.0-beta.4.jar -> jetified-apollo-normalized-cache-incubating-jvm-4.0.0-beta.4 (com.apollographql.apollo3:apollo-normalized-cache-incubating-jvm:4.0.0-beta.4) and apollo-normalized-cache-jvm-4.0.0-beta.4.jar -> jetified-apollo-normalized-cache-jvm-4.0.0-beta.4 (com.apollographql.apollo3:apollo-normalized-cache-jvm:4.0.0-beta.4)
Hmm it looks like your project depends on both apollo-normalized-cache and apollo-normalized-cache-incubating. Can you maybe try ./gradlew :app:dependencies to understand why?
By the way, head up that since the RC1 release of Apollo Kotlin 4, we've changed the group ids, and moved the incubating library outside of the main repository (a bit of context about this here) - so your dependencies should now be:
Question
Version 4.0.0-beta.4
Hi,
In our schema we have an object like this:
And we have a CacheKeyGenerator like so:
We can receive this SimpleUser object from multiple different queries, and each time we receive it, it can contain a different array of
Book
andSomeObject
, which results in the newest receivedSimpleUser
overwriting the previous one. Is there an easy way for me to merge the new and old arrays every time we receive aSimpleUser
regardless of which query it comes from?Thank you!
The text was updated successfully, but these errors were encountered: