Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic connectivity refetch for query watcher #3463

Closed
majda107 opened this issue Oct 18, 2024 · 4 comments
Closed

Automatic connectivity refetch for query watcher #3463

majda107 opened this issue Oct 18, 2024 · 4 comments
Labels
question Issues that have a question which should be addressed

Comments

@majda107
Copy link

majda107 commented Oct 18, 2024

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.

@majda107 majda107 added the question Issues that have a question which should be addressed label Oct 18, 2024
@AnthonyMDev
Copy link
Contributor

AnthonyMDev commented Oct 18, 2024

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.

@AnthonyMDev AnthonyMDev closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2024
Copy link
Contributor

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.

@majda107
Copy link
Author

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.

@AnthonyMDev
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issues that have a question which should be addressed
Projects
None yet
Development

No branches or pull requests

2 participants