【发布时间】:2021-07-11 18:10:15
【问题描述】:
我正在尝试实现更新功能,因此我正在使用 GraphQL 突变。但是,我需要能够检测突变何时完成,以便我可以运行刷新功能。
到目前为止,我的突变:
const handleParameterUpdate = () => {
let active = true;
(async() => {
await updateParameterMutation({variables: {
parameterId: props.parameter.id,
newField: newFieldValue;
}});
if (!active) {
return;
}
})().then(props.updateParams());
}
在我的父组件中:
const handleRefresh = () => {
refetchJobParams({
id: parent.id
});
}
我的意图是在突变完成后运行handleRefresh 函数。到目前为止,它在handleParametersUpdate 之后立即运行,因此,我需要刷新以获取新的新参数。
【问题讨论】:
标签: reactjs graph apollo-client react-apollo