【发布时间】:2018-05-12 20:09:56
【问题描述】:
我正在使用 React Apollo GraphQL 命名突变来调用具有特定名称的突变,只是因为我在同一个组件中有多个突变。当我使用 options.update 更新缓存时,不会调用更新。
我的多重变异代码是这样的:
导出默认值
作曲(
graphql(
SaveRuleMutation,
{
name: 'SaveRule',
options: {
update: (proxy, data) => {
//Not getting invoked
}
}
}
), 图ql( 更新规则变异, { 名称:'更新规则', } ) )(面板);
下面是我的突变调用:
SaveRule({
variables: {
name: values.name,
panelId: panelId,
where: values.where,
sort: values.sort
},
optimisticResponse: {
panelView:{
__typename: 'PanelViewMutation',
}
__typename: 'PanelView',
create: {
id: -1,
name: values.name,
panelId: panelId,
where: values.where,
sort: values.sort
},
},
})
.then(function(ruleObj){
console.log('ruleObj', ruleObj)
})
.catch(function(error){
console.log('error', error)
})
【问题讨论】:
-
您解决了这个问题吗?现在面临同样的问题。所有文档都已更改,因此我只能找到基于组件的示例。
标签: reactjs graphql react-apollo