apollographql / apollo-link-state

✨ Manage your application's state with Apollo!
MIT License
1.4k stars 100 forks source link

Local mutations blocked by network mutations #263

Open brummelte opened 6 years ago

brummelte commented 6 years ago

Mutations are run after one another. If I switch to offline mode, then run a network mutation and then run a local mutation, the local mutation isn't run until I switch back to online mode.

This would make the app unusable for flaky or offline network conditions.

I would expect the apollo-link-state to use its own queue for mutations. So client mutations can be run without waiting for network mutations.

fbartho commented 6 years ago

I totally agree, but I think we need to fix this at the Apollo-link or Apollo Client levels?

I don’t think this link can change execution order in Apollo. — have you tried using a switchLink to split Apollo-link-state queries from GraphQL? (I have a suspicion this isn’t doable)

We may even need a feature to control if Apollo attempts anything offline. (Assuming it does not, today)

brummelte commented 6 years ago

Haven't tried the switchLink yet. Wanted to know if there are any known solutions first.

Offline works already. It just stops working when there is a network mutation in the queue.

And I guess even waiting 500 ms for a network mutation until a client mutation runs will make apps unnecessarily slow.

Only problem I see is that maybe some mutations would need to wait for others to finish first. But I can't see a use case right now. You could just await the network mutation before running client mutations in those cases.