-
Notifications
You must be signed in to change notification settings - Fork 783
Network error: Network request failed #758
Comments
Same problem here, I have no idea how to handle errors when the user is offline. |
There was a mistake in my application logic. I was executing the query on the index (Login) page. Which leads to the network failure and application crashes. The exception was not handled so i handled it now by checking that
|
@saadbinsaeed Can you repost your Apollo client code inclusive of your exception handling, so as to ascertain where it's being handled. Are you handling it within 'networkInterface.use' or catching it after your mutation? |
Hi @TheoMer Sorry for replying late, I am not handling it within the networkInterface.use, i just catched the exception after the query execution. I am not posting the code because it do not follows the Actual Apollo's standards although it is working :P But I will try to explain that what causes trouble to me. May be you are also following the same approach. Let me explain you the scenario. LoginContainer ( index ) page was wrapped in a query and a mutation This is my query and mutation
According to the apollo-documentation when you wrap a component in graphql query, it automatically calls. So in my opinion you have to manually handle the exception in each component which is wrapped in a query. When i start the app on offline mode, Login container renders, try to execute the query, app crashes. This query should have been executed in componentDidMount() of the LoginContainer so that user may able to see at least the login screen in case of offline mode or the developer should have used the refetchQueries option after the execution of its mutation. Each component which is wrapped in a query should handle the exception although this is horribly repetitious,
I hope that i didn't confuse you much. |
Hi @saadbinsaeed Many thanks for your reply. My issue was I presumed cachePolicy and fetchPolicy were going to resolve the issue, but alas not:
I will make the appropriate amendments as you explained. |
My Pleasure @TheoMer, I was first assuming that this is due to the |
I always got this error in my application ( react-native ) when my mobile is not connected with internet. Googled it a lot but cant resolve. It works perfect when internet is connected. Here is my networkInterface code
As i already said it works perfect when my app is connected with internet. But my application crashes when its not. How can i handle this error?
ExceptionsManager.js:71 Unhandled (in react-apollo) Error: Network error: Network request failed
Version
The text was updated successfully, but these errors were encountered: