I'm handling the error with useMutation error handling method however after i attempt to test the error handling by posting an empty post it shows the error in the UI then right after the app breaks and i get the error above.
const [createPost, { error }] = useMutation(CREATE_POST_MUTATION, {
variables: values,
update(proxy, result) {
const data = proxy.readQuery({
query: FETCH_POSTS_QUERY,
});
let newData = [...data.getPosts];
newData = [result.data.createPost, ...newData];
proxy.writeQuery({
query: FETCH_POSTS_QUERY,
data: {
...data,
getPosts: {
newData,
},
},
});
values.body = '';
}
});
''
{error && (
<div className="ui error message" style={{ marginBottom: 20 }}>
<ul className="list">
<li>{error.graphQLErrors[0].message}</li>
</ul>
</div>
)}