I don't get error or data from use mutation after executing #4769
-
Hi, I try to get the error or data after execute the use mutation but I get undefined always in both variables data and error though there is a error I catch it. const [login, { loading, data, error }] = useLoginMutation();
onSubmit={async (values, { setSubmitting, setStatus }) => {
setSubmitting(false);
const variables = { key: values.key, password: values.password };
try {
const response = await login({ variables });
if (response && response.data) {
history.push('/');
} else if (response.errors) {
setStatus(response.errors);
}
} catch (err) {
console.log(error); // undefined
console.log(err);
setStatus(error);
}
}} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@AbderrazzakB can you please share a reproduction of that issue? the generated signature of |
Beta Was this translation helpful? Give feedback.
-
Hi @dotansimha, OK I found out what was wrong, not sure why or how but I think when there is an error my mutation throw an error and it did reach my catch error before the mutation error property gets updated. because in the render I can see the error and display the error message from it. |
Beta Was this translation helpful? Give feedback.
Hi @dotansimha, OK I found out what was wrong, not sure why or how but I think when there is an error my mutation throw an error and it did reach my catch error before the mutation error property gets updated. because in the render I can see the error and display the error message from it.