The mutation result returned when useMutation mutate function resolves with errors does not return an ApolloError on error property, but an errors array #7913
Labels
🔍 investigate
Investigate further
Intended outcome:
When reading the mutation result from the resolved promise of a
useMutation
mutate function (whenerrorPolicy
isall
) the format of the result should be consistent with that of theuseMutation
hook itself and as the documentation describes under "Mutation result".Actual outcome:
A vanilla mutation
result
object is actually returned with an emptydata
Object and anerrors
array, rather than anApolloError
on anerror
key:https://github.com/apollographql/apollo-client/blob/main/src/core/QueryManager.ts#L207
useMutation
'supdate
callback is also called with this same object:https://github.com/apollographql/apollo-client/blob/main/src/core/QueryManager.ts#L307
However, the
error
property returned fromuseMutation
is returned correctly.How to reproduce the issue:
In our particular use case, we can't use the
error
returned fromuseMutation
as we are calling the mutate function in a FormikonSubmit
callback and need access to Formik'ssetErrors
function:Versions
System:
OS: macOS 11.1
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
Browsers:
Chrome: 89.0.4389.90
Firefox: 86.0.1
Safari: 14.0.2
npmPackages:
@apollo/client: ^3.2.0 => 3.2.0
@apollo/link-error: ^2.0.0-beta.3 => 2.0.0-beta.3
The text was updated successfully, but these errors were encountered: