Apollo writeFragment返回未定义,但readFragment有效

时间:2019-04-26 07:21:39

标签: javascript reactjs apollo react-apollo

事件完成后,我正在尝试更新缓存。我从我的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)

enter image description here

0 个答案:

没有答案