Closed bglgwyng closed 1 year ago
Hi @bglgwyng, have you tried onPublish function https://github.com/morrys/react-relay-offline#environment-with-offline-options?
@morrys From my observation, onPublish
is called whether it's online or not and also whether it's succeeded or failed.
So I think that I need to filter operations to be queued by looking at the value of offlinePayload.request.payload.operation
.
Then, this indicates that I'm going to write the logic that decides which mutations are queued in the one place, that onPublish
. And I'm not fully satisfied with this solution.
Do I understand correctly? Or am I missing something?
yes, you understood correctly, onPublish is called only when an offline mutation is performed, you can use the metadata field of cacheConfig, adding for example skipOffline: true, to change the behavior of onPublish
Thank you for your kind reply!
As far as I know,
react-relay-offline
's default behavior is keeping mutations in the queue until the network is back online. I read some code ofreact-relay-offline
and I couldn't find any way to change this behavior. But I want to send mutations only when the network is online. At least for some mutations. For example, it seems quite weird that the sign-in mutation is kept in the queue and resent when the network is back online. It'd be better just to throw an error when the network is offline in this case.I found one way to do that, but it's a bit ugly.
Is there any better way to do that?