简体   繁体   English

Apollo反应突变更新查询未调用

[英]Apollo react mutation updateQueries not calling

I was trying to check the arguments of the updateQueries function to update the component's props with the new information, but it seems that the function is not being called, any idea why? 我试图检查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
        };
    }
});

This seems to be the same question as: Apollo updateQueries Not Called? 这似乎与以下问题相同: Apollo updateQueries未调用?

The answer is the same as well. 答案也一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM