twenty
twenty copied to clipboard
refactor: refactor Optimistic Effect registration
This PR is a suggestion to simplify some aspects of optimistic effect registration.
optimisticEffectWriter always does the same thing:
- read data from Apollo cache
- compute updated data with a resolver
- update data in Apollo cache
Instead of wrapping the resolver with a writer and saving the writer in the Recoil State, this saves the resolver directly in the Recoil state and the "read data/update data in cache" logic is moved to triggerOptimisticEffects.
I also removed the query from the optimistic effect as right now we only use the optimistic effects with findManyRecordsQuery, but it can be added back if needed.