aerogear / offix

GraphQL Offline Client and Server
https://offix.dev
Apache License 2.0
758 stars 45 forks source link

Network state should be checked before hitting client mutate #120

Closed wtrocki closed 5 years ago

wtrocki commented 5 years ago

Definition of the problem

Currently, when performing offline mutate operation we going to apply optimistic response updates twice. This approach also requires users to pass the global cache update function, which is not convenient.

Solution

We can return error to the user and check network state directly in the helper making. Offline link then will be able to enqueue the changes as always but this time we going to know that this operation was marked as offline. This will help us to introduce server state aware offline cases where developers can specify some function that will quality changes to be enqueued to offline queue after network request.

wtrocki commented 5 years ago

Ok.. After quick investigation of this I think that we can move even farther from client.mutate and make network state checkbeforehand. This will mean that there will be extra offlineFlag to context that will be triggering offline link to store mutations. I could not find any side impacts of this change and going to create quick prototype now

wtrocki commented 5 years ago

This is already addressed in https://github.com/aerogear/offix/pull/170

wtrocki commented 5 years ago

ping @darahayes