useMutation 的 onCompleted 即使出错也会执行

onCompleted of useMutation get executed even on error

当我使用 useMutation 挂钩并收到响应错误时,将触发 onCompleted 方法。这是正常行为吗?

 const [createPerson] = useMutation(CreatePerson, {
   onCompleted: () => {
     console.log('even onError it`s executed')
   }
 })

根据我们在聊天中的讨论,我认为您已将 Apollo Provider 的错误策略设置为 ignore:

ignore: Ignore allows you to read any data that is returned alongside GraphQL Errors, but doesn't save the errors or report them to your UI.

这就是 GraphQL 错误被忽略的原因。它们只会在使用 none.

的默认策略时被触发

有关错误政策的更多信息here and in this