![](/img/trans.png)
[英]updateQueries after GraphQL mutation not working with the Apollo client
[英]Apollo react mutation updateQueries not calling
我试图检查updateQueries函数的参数以使用新信息更新组件的props,但是似乎未调用该函数,为什么?
mutation toggleTodo($id: ID!) {
toggleTodo(id: $id) {
completed
}
}
const withMutations = graphql(TOGGLE_TODO_MUTATION, {
props: ({ ownProps, mutate }) => {
return {
onTodoClick: id => mutate({
variables: { id },
updateQueries: {
toggleTodo: (prev, { mutationResult }) => {
console.log(prev);
console.log(mutationResult);
return prev;
}
}
}),
todos: getVisibleTodos(ownProps.todos, ownProps.filter),
...ownProps
};
}
});
这似乎与以下问题相同: Apollo updateQueries未调用?
答案也一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.