apollo-client: useMutation onError handler is not fired if error policy is set to "all"

Issue Description

Intended Outcome

From the docs the onError policy is called unless the errorPolicy is set to ignore.

Actual Outcome

useMutation onError handler is not called when an error occurs on the graphql server and the error policy is set to all.

Versions

"@apollo/client": "^3.7.15"

Link to Reproduction

https://codesandbox.io/s/thirsty-darkness-crw7f8?file=/src/index.jsx

Reproduction Steps

  1. Invoke a mutation with an onError handler and errorPolicy: “all”
  2. When an error occurs the onError handler will not be called.

The code sandbox link reproduces the issue.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 19 (10 by maintainers)

Most upvoted comments

This has been fixed in #11103 and will be released with 3.8.0 in the next couple weeks. Thanks for reporting this!

@bignimbus looks like you’re using an errorPolicy of none. I’m able to reproduce if you change errorPolicy to all. onCompleted is called instead in that case.

Ok i’ll see if I can dig that up. Note I’m using apollo server on the server side and that is handling the error formatting.