POC: fine grained storage persister #5125
Draft
+175
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Ref: #4693
This is a POC of a
persisterthat works for bothsyncandasyncstorageThings that are missing from the currently implemented client persister:
throttlingretryout of spaceissues that were reported previouslysingle key storagepersisting paused mutationsHow to run?
cd examples/vue/persisterpnpm ipnpm run devlocalStorageand pages toidbSeems to be working pretty well...
Extending
useQueryapi layer:What we could do to make it even better is to add a
persisterto the option list ofuseQuery.This will allow to pass in
persisterwithout touchingqueryFn.Additionally we would be able to add it to the global
defaultOptionsofQueryClientif we would like to achieve global client persistance with the least amount of code. Without the need to wrap everyqueryFnwith persister.Two additional benefits would be the ability to get rid of
setTimeoutto store the state of query (or maybe we can do it now? I'm not sure). And also we would not have to pushqueryClientto the persister, as it could be passed to the persister along query function context.