Question: Graphcache multiple updates
See original GitHub issueHi all
Lets say i have a system with notifications and chat
notification {
user {
id,
name
}
content:String
}
chatmessage {
user {
id
name
}
message:string
}
I first execute a query to get the list of all notifications and then i subscribe to get subsequent updates. Subsequent updates are merged with the original array using updateQuery
Second i have a chat system in which from the beginning i subscribe to receive new chat messages
The problem is the following If the notifications array contains 100 entities. 95 of them are from the same user and then that same user sends a chat message
Graphcache will update the user in the cache that will result in the notification query to be reloaded thus resulting in the whole notifications component to be rerendered
If the chat system is very busy with many users chatting at the same time then the notifications component will rerender any time a chat arrives which contains a user that also has a notification
I am using react.memo to avoid rerendering each notificatio but the loop on all the notifications will be executed since the notifications array will be refreshed (due to the new chat message)
How should someone handle this kind of situations?
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (7 by maintainers)
Thanks a lot
Some more information.
If i have maskTypeName to true then the objects do come back with a prototype I assume its because its doing something to hide __typename