ApolloClient onError doesn't catch mutation errors anymore
See original GitHub issueHere is my client configuration using Apollo Boost :
new ApolloClient({
uri: `${window.location.origin}/api`,
cache: new InMemoryCache(),
onError({ graphQLErrors, networkError }) {
if(graphQLErrors)
graphQLErrors.forEach(error => notification.error({
message: 'Error',
description: error.message
}))
if(networkError)
notification.error({
message: 'Network Error',
description: `A network error has occurred. Please check out your connection.`
})
},
request(operation) {
const currentUser = readStore('currentUser')
currentUser && operation.setContext({
headers: { authorization: currentUser.token }
})
}
})
Intended outcome: Before the bug, the onError callback used to catch errors just fine.
Actual outcome: Errors are said to remain uncaught and cause apps (using CRA in my case) to crash.
How to reproduce the issue: Try switching to the latest version of apollo-boost and just throw a Graphql error on the server.
Versions React : 16.12.0 Apollo-boost : 0.4.7
Issue Analytics
- State:
- Created 4 years ago
- Reactions:47
- Comments:48 (7 by maintainers)
Top Results From Across the Web
Handling operation errors - Apollo GraphQL Docs
Apollo Client can encounter a variety of errors when executing operations on your GraphQL server. Apollo Client helps you handle these errors according...
Read more >Error handling - Apollo GraphQL Docs
By default, the error policy treats any GraphQL Errors as network errors and ends the request chain. It doesn't save any data in...
Read more >Mutations in Apollo Client - Apollo GraphQL Docs
A callback function that's called when your mutation successfully completes with zero errors (or if errorPolicy is ignore and partial data is returned)....
Read more >Handling Errors with Apollo Client (React) - YouTube
In this video I talk about handling errors when running queries and mutations using Apollo Client in a React project.Table of contents:00:00 ...
Read more >GraphQL error handling to the max with Typescript, codegen ...
We'll see in this article how to: achieve a better error representation than the default offered by GraphQL; get type safety using Typescript ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any update on this? I have a pretty large app that relied on this pattern to minimize the amount of try/catch and .catch that was needed. Made for a super clean code base knowing I could rely on apollo-link-error when needed.
Not sure what changed, guess I need to look at my past few commits, but lately all mutation errors throw an unhandled error.
Is this change documented in a change log somewhere?
Any updates on this one? I can’t believe this issue still not addressed yet