apollo cache modify isn't reflected in previous screen directly

Viewed 45

I update cache after mutation in apollo-client.

And I check all that cache is correctly modified by printing console.

however when navigation.goBack() to previous screen, caption contents is not reflected in screen.

Precisely, when It's the first mounted screen, it's not updated. But once It's refreshed, it is working well.

what is the problem here?

  const onUpdateEdit = (cache, result) => {
    const {
      data: {
        editFeed: { ok },
      },
    } = result;
    if (ok) {
      cache.modify({
        id: cache.identify({
          __typename: "Feed",
          id: feedId,
        }),
        fields: {
          caption(prev) {
            console.log("prev", prev);
            return caption;
          },
        },
      });
      navigation.goBack();
    }
  };

previous screen use seeAllFeeds.

So I tried to update ROOT_QUERY.

but seeAllFeeds looks like below when I console.

It doens't have caption or other fields, so I can't update it.

please help me.

ROOT_QUERY:
seeAllFeeds: Array(1)
0:
__ref: "Feed:12"
[[Prototype]]: Object
length: 1
[[Prototype]]: Array(0)
0 Answers
Related