-
I'm using GraphQL subscriptions for a notification system. The notifications are fleeting, so they're pushed down the subscription pipeline once and have no other back-end storage. The problem that I'm running into is that I'd like to show the notifications in the React UI before a user dismisses them. However, I'm not sure where to store them. What is the best way to move messages from a subscription into some sort of client-side state that I can manipulate without breaking React? Things I've triedI've tried creating a subscription handler which calls a An alternative thought I had was to see if I can write them to the Graphcache cache, but I don't think that's a good idea, because I wouldn't be able to remove them. Since they're not stored on the server but just sent as messages, there would be no mutation to remove them from the cache. The component already re-renders when the subscription data is updated so I thought of just using the return value of the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Why don't you just keep the current notification in the hook's state and use an effect to update a separate store? This way you can build up an index of notifications completely separately from the subscription's state |
Beta Was this translation helpful? Give feedback.
Why don't you just keep the current notification in the hook's state and use an effect to update a separate store?
This way you can build up an index of notifications completely separately from the subscription's state