Open
Description
I'm getting the following type error when following the guide here: https://relay.dev/docs/tutorial/mutations-updates/#step-3--call-readupdatablefragment
Argument of type 'StoryLikeButtonFragment$key' is not assignable to parameter of type 'Readonly<{ ' $data'?: unknown; $updatableFragmentSpreads: unknown; }>'.
Property '$updatableFragmentSpreads' is missing in type 'StoryLikeButtonFragment$key' but required in type 'Readonly<{ ' $data'?: unknown; $updatableFragmentSpreads: unknown; }>'`
Here is the entire onLikeButtonClicked function:
const onLikeButtonClicked = () => {
commitMutation({
variables: {
id: data.id,
doesLike: !data.doesViewerLike,
},
optimisticUpdater: (store) => {
const fragment = graphql`
fragment StoryLikeButton_updatable on Story @updatable {
likeCount
doesViewerLike
}
`;
const { updatableData } = store.readUpdatableFragment_EXPERIMENTAL(
fragment,
story
);
const alreadyLikes = updatableData.doesViewerLike;
updatableData.doesViewerLike = !alreadyLikes;
updatableData.likeCount += alreadyLikes ? -1 : 1;
},
});
};
Metadata
Metadata
Assignees
Labels
No labels