apollo-feature-requests
apollo-feature-requests copied to clipboard
api for debouncing: apply only optimistic update & rollback
Coming from relay, I miss possibility to delay sending of the mutation to the server and apply only optimistic update until there is good time to commit it to server. Typical use case is filling the form. Now its necessary to keep the input values in the component state (or apollo store, but separately from server schema). Idea of including debounce options within apollo was already discouraged.
There was similar discussion in Relay, which also had similar direction that debouncing should not go to the core. But there was good api for it in relay classic and its also somewhat possible with modern api
Using this api its possible to quickly updating UI changes (like writing in input) and commit or rollback at the end. With every input change I could basically apply new optimistic change and rollback the previous one and at the end just commit the last version.
To make more clear how the api could look like - having either option for store.mutate method or separate method (like store.localMutate) that would return object with rollback and commit methods.
Have not spent time with apollo client internals yet, so any feedback on how this is desirable and feasible to implement with current code base are hugely welcomed.
Looking forward to discussion.
- [ ] has-reproduction
- [x] feature
- [ ] docs
- [ ] blocking
- [ ] good first issue
To help provide a more clear separation between feature requests / discussions and bugs, and to help clean up the feature request / discussion backlog, Apollo Client feature requests / discussions are now being managed under the https://github.com/apollographql/apollo-feature-requests repository.
This feature request / discussion will be closed here, but anyone interested in migrating this issue to the new repository (to make sure it stays active), can click here to start the migration process. This manual migration process is intended to help identify which of the older feature requests are still considered to be of value to the community. Thanks!
Re-opening and transferring to the feature-request repo.