-
Hi! As I mentioned in #1068 (reply in thread) I'm trying to use urql for a scenario where I expect users of a native app to be offline for long enough stretches of time wherein they can perform a number of mutations, each of which would create a "Recommendation" entity. For this I'm using a custom updater offlineExchange({
storage, // <--- I created this using AsyncStorage
schema,
updates: {
Mutation: {
createRecommendation: (result, args, cache, info) => {
const recommendation = .... // builds recommendation from args
const fieldId = ... // gets field Id from args
cache.updateQuery({ query: QUERY_RECOMMENDATIONS, variables: { fieldId } }, (data) => {
data.recommendations.push(recommendation);
return data;
});
},
},
},
optimistic: {
createRecommendation: ... // creates a Recommendation entry
}
}); This works the first time: even if the device is disconnected, I can see the newly-created recommendation if I use the client to query Is there a way these offline updates can be cumulative, i.e. I could create one recommendation after the other and see them all while the device is offline? Thanks! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
That's pretty odd! I'm trying to think of what could be causing this, because optimistic updates should always allow you to cumulatively add to a list already. So let's debug this and maybe I can write a new test for our test suite to make sure that this is indeed broken and then subsequently fix it if it's indeed buggy. So on the second optimistic You said that it's called but lacking the previous recommendation; that's all while the device was offline and only optimistic updates were made, right? |
Beta Was this translation helpful? Give feedback.
That's pretty odd! I'm trying to think of what could be causing this, because optimistic updates should always allow you to cumulatively add to a list already. So let's debug this and maybe I can write a new test for our test suite to make sure that this is indeed broken and then subsequently fix it if it's indeed buggy.
So on the second optimistic
createRecommendation
call ofupdates.Mutation.createRecommendation
, have you verified that it's indeed called, that the list is missing the last recommendation, or whether any other weird behaviour already occurs there?You said that it's called but lacking the previous recommendation; that's all while the device was offline and only optimistic…