这是我的代码
在阿波罗客户端中,我使用useMutation。
阿波罗客户
const [addTodo,{ loading,error,data }] = useMutation(gql);
阿波罗服务器
Mutation: {
signUp: async (_,formSignUp,{ models: { User },res }) => {
try {
const user = new User(formSignUp);
await user.save();
const token = await user.generateAuthToken();
res.cookie("darkAmasia",token,{
httpOnly: true
});
return "string";
} catch (error) {
?????????
}
}
}
我该怎么写?在useMutation错误中发送消息{status:400,error:true}
。
我听说throw new ApolloError
用于这些目的。但是我不知道该怎么做。