apollo-ios
apollo-ios copied to clipboard
Feature Request: option to provide restoration objects for optimistic caching
If we could optionally provide mutations with restoration objects that are the same shape as the expected result data, then in case of an error, this restoration object could come back within the failure error, and be used to restore the cache, or any optimistic changes. I'm not sure that this would need to work directly/automatically with the cache at all. If one decides to take any optimistic action, then they can rely on this object to unwind, be it caching or just view updates.
I like the idea of supporting optimistic caching.
Realistically, it's going to have to wait until the mutable rewrite of the the cache as part of phase 3 as outlined in the swift codegen RFC is done, but I definitely want to support this at some point.
@designatednerd does this mean we currently can't update fragments even though an interface for one does exist?
You should be able to update anything non-optimisitcally using the direct cache modification methods - this issue is just asking about optimistic caching, which basically means "assume your query will succeed, and provide a rollback function for when it doesn't".