Update Query State - based on SignalR recieved data
Hi all.
What would be the best way to update a already fetched query with data state that comes from a SignalR message?
I want to use the data state that was sent from the BE and overwrite the query state?
Cheers.
5 Replies
extended-salmon•4y ago
I'm going into details on how to handle real time push updates here:
https://tkdodo.eu/blog/using-web-sockets-with-react-query
Using WebSockets with React Query
A step-by-step guide on how to make real-time notifications work with react-query
sunny-greenOP•4y ago
@TkDodo 🔮 thanks for the link! Will read it all!
I managed to figure it out before your reaponse. But can’t use it because the signalR message data doesn’t consist of correct data structures 🙂
extended-salmon•4y ago
What does it consistently of?
sunny-greenOP•4y ago
Well the thing is that the initial query returns a object ( which basically displays locations in a parent/child reference ) and the message update from the socket comes back as a list with no path key which of the lists should be updated. And have to be changed by the BE Team 😄
extended-salmon•4y ago
yeah if you don't know to which part / key of the queryCache you should write that information to, you can't update the cache 🙂