Open
Description
This is a question to start but it could become a bug or be closed, depending on the discussion here.
I am trying to use MockedProvider
to test an error scenario with a custom code sent into the extensions. I noticed there is a different behavior going on between MockedProvider and ApolloProvider.
Does MockedProvider behave differently from real ApolloProvider for mutation promise chain?
const [changePassword, { loading }] = useMutation(CHANGE_PASSWORD);
const handleSubmit = (formValues) =>
changePassword({
variables: {
input: {
currentPassword: _.get(formValues, 'currentPassword'),
newPassword: _.get(formValues, 'newPassword'),
},
},
})
.then((response) => {
// This runs for MockedProvider, even when there is no data and there is an error.
// This never runs for the real ApolloProvider when is no data and there is an error.
})
.catch((error) => {
});
Sample response:
{
"errors":[
{
"message":"Invalid password",
"locations":[... ],
"path":[
"changePassword"
],
"extensions":{
"code":"INVALID_PASSWORD_ERROR",
"exception":{
"stacktrace":[...]
}
}
}
],
"data":{
"changePassword":null
}
}
It seems like the execution of the changePassword
mutation in the real app (ApolloProvider) throws an exception and jumps straight to the catch.
Activity