我试图检查updateQueries函数的参数,用新信息更新组件的道具,但似乎没有调用该函数,不知道为什么?
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
};
}
});