In the message read function, I had to update "already read" for the number of messages that have been made in the message details page. Certainly I want to be able to use Batch and update at one time, I can't find the way right now, so I feel better
メッセージの既読機能で、メッセージ画面詳細で任意の数だけ行われているメッセージ分の「既読」更新をしなければならなかった. 確かにBatchをつかって、1回で更新できたらいいけど
[react-apollo]How to call any number of multiple mutations after getting query result (not Batch)
const MessageDetail = ( props ) => {
useEffect(() => {
(async () => {
const { data } = await props.client.query({ query: messageQuery, variables: { id: props.match.params.id }});
const shouldCallMutationForDoneRead = data.messages.nodes.map( e => e.id);
shouldCallMutationForDoneRead.forEach( id => {
props.client.mutate({ mutation: readMessageMutation, variables: { messageId: id }, refetchQueries: ["unreadMessagesQuery"]}).then( d => {
console.log(d, "done mutation");
});
});
})()
},[]);
.
.
.
.
}
・ error handling ・ await mutation