Closed majda107 closed 1 month ago
There isn't any way to do this baked in to ApolloiOS
. You could probably make this work with some complex interceptors, but I think this is better suited for just wrapping the query watcher in your own object that handles any custom behaviors such as this.
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.
Maybe it would be good idea to introduce this in future versions? In android (kotlin) apollo client, you can simply toggle retryOnNetworkError interceptor flag and this behavior is handled automatically.
For me it simply seems like a no-brainer, to be able to automatically load data that failed due to lack of network connectivity. For general usecases like loading list of entities you want to display the data to the user as much as possible, also you already have the stream publisher -> view pipeline that requires to be implemented in a reactive way, so Its just a matter of calling refetch on specific network error code and NWPath value observation.
I lean toward this being something better left to users to implement themselves right now. Not everyone wants this behavior, and will likely want it to function a little differently. Maybe at some point in the future we could introduce this, but I don't anticipate us investing in supporting this in the SDK in the near future.
Question
Hello, is there a built in mechanism that would allow query watcher to automatically refetch data when network error occured in previous call + network connectivity was restored (NWPath went from unsatisfied to satisfied).
I have built my own extension that does call refetch() on both watcher and pager (from apollo-ios-paging extension), but I think there may be more “native” approach using interceptors? Only thing I am not sure, is how to force interceptor to “stream” new data to the query watcher.