事件完成后,我正在尝试更新缓存。我从我的selectedEvent片段缓存事件数据,然后尝试将更改写入缓存。
readFragment有效:
const event = client.readFragment({
id: `Event:5cc16ebcc922430697c49dea`,
fragment: gql`
fragment selectedEvent on Event {
_id
title
start
end
done
}
`;
});
console.log(event)
writeFragment不起作用,并返回未定义:
const updated = store.writeFragment({
id: `Event:5cc16ebcc922430697c49dea`,
fragment: gql`
fragment finish on Event {
done
}
`,
data: {
done: true,
__typename: "Event"
},
});
setEvent(updated)
console.log(updated)