-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
errorPolicy ('ignore' and 'all') doesn't work in case of network error #3034
Comments
Note that this is also an issue for response code 400. If you throw an error from your resolver in the server, then that error will be returned when errorPolicy is set to 'all', but if there's an error in your query (e.g. invalid field) then it just returns this generic message:
|
apollo-client/packages/apollo-client/src/core/QueryManager.ts Lines 503 to 508 in 905001e
Shouldn't be:
|
I'm having the exact same issue. Sending a query that doesn't follow the schema results in a network error as described here. It also returns a GraphQLError, but I can't access that because the network error is throwing regardless of my |
I'm running into this too. Using The errorPolicy and Network Errors docs make it sound like these network errors shouldn't go unhandled like this with the |
So this issue has been open for a really long time and ( unless I and others in this thread have a complete misunderstanding of how apollo should handle these errors ) It seems very high priority. Again to summarize the big issue here: ITS CURRENTLY IMPOSSIBLE TO GET ACCESS TO RELEVANT ERROR INFORMATION WHEN A NON 200 STATUS CODE IS RECEIVED. I have been using apollo for nearly a year now and my work around has been to never set a field to |
@joepuzzo I would not sacrifice the correctness of your schema because of this. A better workaround is to go to the network tab in dev tools where you can see the full error message. But yes, this is a significant issue in Apollo client and should be fixed. |
LOL yes i as a human can go to the network tab and see my errors. I need my code to do it though LMFAO 😆 . Agreed very big issue |
@hwillson Maybe you can at least give some clarity into this issue as its been going on for so long. Are we just misunderstanding the design? Or is this a bug? |
Going to the network tab is a good way to debug it in development but this does not cover:
Network errors are going to happen. It may be a transient error for 1 request. That shouldn't brick the app when it happens on a server render. I agree with you @joepuzzo this is either a huge issue / design flaw or we are not using it in the intended way. The issue is over 1 year old with not response from the core team. @benjamn @hwillson |
Would anyone here be able to provide a small runnable reproduction that clearly shows this issue? This sounds more like an Apollo Link (https://github.com/apollographql/apollo-link) issue, but a repro would help confirm. |
Thanks for the quick response @hwillson. I will put together a repo to reproduce it. It very well may be apollo-link. |
@brandondoran I have created these two sandboxes to help show this issue #4644 and i think also pertains to this issue as well. https://codesandbox.io/s/w7qy5m1pw7 << UI using apollo client A couple things to note:
|
To reproduce: Go to the home page and refresh the browser. Then navigate to the dog page. You will see an error. Then navigate back to |
apollo-client/packages/apollo-client/src/core/QueryManager.ts Lines 573 to 575 in d33eb3e
Edit: if (errorPolicy === 'none' && (hasGraphQLErrors || queryStoreValue.networkError)) |
Thanks for reporting this. There hasn't been any activity here in quite some time, so we'll close this issue for now. If this is still a problem (using a modern version of Apollo Client), please let us know. Thanks! |
This is still an issue ... |
@jbaxleyiii Can you reopen this please? |
I don't want to have to return a 200 in the case when the request errors out in a way that the user needs to know about, but I don't see any other path forward if this remains as is.... it just eats any 400 responses and doesn't allow for the configuration parameter that is supposed to override this option to do its job so I can let the user know what the error is somewhere other than the dev console, so they can go and fix it. What is the alternative? Edit: the alternative ended up being switching to Urql. |
@jbaxleyiii I am experiencing the issue. I can't get GraphQL error because of the network error when response's status code is different than 200. |
I found this issue one year ago and I'm still struggling with that. Anyone could find a workaround? Like it was already said, if you have a network error in meaningless request during SSR everything breaks :/ |
I would also like to have this reopened |
You're probably better off opening a new issue. Just speaking generally (not even specific to Apollo), closed issues rarely get attention from maintainers. |
Intended outcome:
Solution 1: In case of a network error errorPolicy set to 'ignore' or 'all' should prevent unhandled Apollo exception.
Solution 2: If this is expected behaviour, please update the official documentation.
Actual outcome:
Network errors cause unhandled Apollo exception even if errorPolicy is set to 'ignore' || 'all' on query options and ApolloClient defaultOptions level.
How to reproduce the issue:
Create a network request which returns response code 401.
Use errorPolicy set to 'ignore' || 'all' in query options, or in ApolloClient defaultOptions.
Version
The text was updated successfully, but these errors were encountered: