twenty icon indicating copy to clipboard operation
twenty copied to clipboard

refactor: refactor Optimistic Effect registration

Open thaisguigon opened this issue 1 year ago • 0 comments

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.

thaisguigon avatar Jan 05 '24 18:01 thaisguigon