Comments (7)
This seems to be a custom case outside offix scope. You might get much better results with the:
- Apollo-Link-Queue
- Apollo-Cache-Persist
Those two + your logic for letting users to review the changes are much better and easier way to get this done.
from offix.
I took a look at both packages. Just to be clear I already have the manual push working just fine with offix and a custom networkStatus object. I think that was the intention behind Apollo-Link-Queue being suggested?
I'm specifically looking for a way to revert a offline mutation. I still want the features of offix such that remote server data is stored separately from local changes and then are merged into a computed in memory state. I'm under the assumption that if I were to use Apollo-Cache-Persist I would lose this functionality. I think its important to be able to pull down new remote data and be able to blow away the old data with out any worries.
I saw the video here and it also lists the users offline mutations. I didn't think simply deleting a mutation would be out of scope.
https://www.youtube.com/watch?v=CrYinCtTHds&ab_channel=WojtekT.
If I use dequeueOperation to delete a operation is there a way to force offix to re-compute the in memory state as it does on page loads without actually doing a page load? Otherwise I will probably go with my suggested work around above.
Maybe I'm dumb and I don't see how the two packages you suggested would be helpful.
Thanks,
Mitch
from offix.
Let me think.. queue is managed automatically and it is available to call from client.
https://github.com/aerogear/offix/blob/master/packages/offix/client/src/ApolloOfflineClient.ts#L42
This will allow you to do it in offix. Trick is that generally we do not support this because if there is some other operation happening queue could get into wrong state. Then queue contains raw changes which means that if one item is removed other in queue others will be affected. - removing create wil affect edits.
If you are aware of those challenges and handling this well in your code then operations on queue should be good for you
from offix.
Also you still going to get optimistic responses on Apollo visible. Those are separate to queue..Means that after user reviews it you need to wipe out all optimistic responses that will be now orphaned since queue items for those might have been removed
from offix.
Yea for something like create, with other changes on top of that same entity I was thinking that a user could only revert the last change for a given entity so order is preserved and I was going to handle that complexity in my application. So you could not revert a create with out first reverting the other changes on that object.
I wasn't aware apollo stores optimistic responses in a queue I thought it just mutated the in memory data in place. I guess I will just try my suggested work around above and test if orphaned optimistic responses will cause any issues or find a way to clear them.
Thanks for your help.
from offix.
I gave this more thought and I may have a better idea. I noticed that the queue also has updateOperation. What if instead of actually deleting anything I just update operations in a way that they are simply flagged. My application would no longer show flagged changes, changes would become flagged when reverted by the user. When the user reverts a new offline mutation would be made to properly set the new in memory state. This would accomplish all the same goal while avoiding any orphan issues, it does keep a lot of useless changes in memory but I think that's fine.
from offix.
My above solution was sufficient for my use case.
from offix.
Related Issues (20)
- Action Required: Fix Renovate Configuration
- Issue with nested objects in variables HOT 2
- Expose network status change HOT 3
- npm package seems out of date for react-offix-hooks HOT 2
- Docs concept page is blank
- Offline Search dgraph
- Error subbscribeToUpdate is undefined at react-native example project
- How offix supports File offline upload ? HOT 4
- Dependency Dashboard
- Add ability to build query that includes all relationships
- Ability to provide late binding for datastore queries. HOT 9
- Please export ApolloQueryResult from offix HOT 2
- Getting error while build project HOT 1
- OfflineStore removeEntry expects v1:queue:yyyy but it's called with queue:yyyy HOT 3
- Interfaces versus Types generation HOT 1
- Aggregate Hooks Issue HOT 1
- Simplify Datastore flow HOT 4
- _super.call is not a function, with fix HOT 6
- rxDB integration / offix Limitations HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from offix.