I'm refactoring (for fun, ha) my redux application to relay. In the redux application a failed event would dispatch an action with the failure message.
This would be picked up by an 'Alert' reducer that would then present an alert to the user. This would be kept in the global state for x seconds before being removed.
The Alert component would sit empty until there were alerts dispatched to fill it.
How would this be done under Relay? Is there a way to mutate only the Store rather than dispatching a GraphQL mutation?
Thanks for the help :)
One option would be to have alert in your schema (you could even just include it in your local schema, though you'd probably have to change the way babelRelayPlugin gets its schema) and use applyUpdate to change it. I have never tried that, nor do I think it's what the devs had in mind for it, but it might just work.
In its current version Relay isn't really made for local state, but apparently it's on the roadmap for Relay 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With