我使用React Apollo GraphQL命名突变来调用具有特定名称的突变,因为我在同一组件中有多个突变。当我使用options.update更新缓存时,更新不会被调用。
我的多重变异代码是这样的:
导出默认值
作曲(
graphql(
SaveRuleMutation,
{
name: 'SaveRule',
options: {
update: (proxy, data) => {
//Not getting invoked
}
}
}),graphql( UpdateRuleMutation,{ name:'UpdateRule',}))(面板);
下面是我的突变呼叫:
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)
})发布于 2017-11-29 17:42:24
我相信您的optimisticResponse格式不正确。它应该是:
optimisticResponse: {
__typename: 'PanelViewMutation',
create: {
__typename: 'PanelView',
id: -1,
name: values.name,
panelId: panelId,
where: values.where,
sort: values.sort
}
}https://stackoverflow.com/questions/47547331
复制相似问题