【发布时间】:2017-10-28 19:34:42
【问题描述】:
我有一个如下所示的 graphql 架构:
type User {
entries(status: EntryStatus): [Entry]
}
type Mutation {
updateEntry(status: EntryStatus): Entry
}
我可以按状态过滤条目列表(这是一个枚举),我可以更新条目的状态。我想在状态更新时更新商店,以便条目出现在正确的列表中(entries(status: FOO) 到 entries(status: BAR))。
我知道我可以使用 update 方法更新商店。
const withMutation = graphql(updateEntryMutation, {
props: ({ mutate }) => ({
updateEntry: updateEntryInput =>
mutate({
variables: { updateEntryInput },
update: (proxy, newData) => {
// update data here
// Which would involve removing the entry from its previous filtered "list", and adding it to the one with the new status
})
})
});
但是由于我无法访问 update 的旧数据(以前的 entry.status),我怎么知道要从哪个列表中删除条目?
(除了按状态枚举所有列表并删除更新的条目,如果我发现它......)
【问题讨论】:
标签: javascript graphql apollo react-apollo