From bbc01e341151e2b42e97e5462dd749f6be47b326 Mon Sep 17 00:00:00 2001 From: Ivan Santos Date: Wed, 27 Mar 2019 14:11:39 -0700 Subject: [PATCH 1/2] feat: adds support to optional function errorsCheck and parseAndHandleHttpResponse errorsCheck throws errors by default if available. parseAndHandleHttpResponse throws error by default if there's a problem with http response. From 888fa7228030e49e42c6ce98a13bb4fb4b795406 Mon Sep 17 00:00:00 2001 From: Ivan Santos Date: Wed, 24 Apr 2019 13:29:15 -0700 Subject: [PATCH 2/2] feat: add skip offline support --- README.md | 1 + src/index.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 92c2f7b..1e926f7 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ The only *REQUIRED* variable to date is `actionType` - `payloadFormatter(payload)` Optional Function to format the response coming back from GraphQL on a successful retrieval. `payload` is provided as a parameter. This function returns back the modified data. This is a good place to run data normalizations - `errorsCheck(result)` Optional Function to give the client the choice for whether it should throw an error if errors are present on GraphQL response. It throws an error by default if function is not provided. - `parseAndHandleHttpResponse(operation, result)` Optional Function to give the client the choice for whether it should throw an error if there's an HTTP/GraphQL schema error present on GraphQL response. It throws an error by default if the function is not provided. + - `skipOffline` Skips offline check returning error right away if connection can't be stablished. --- diff --git a/src/index.ts b/src/index.ts index b640a6e..193ffdd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -160,12 +160,14 @@ const reduxOfflineApolloLink = ( ); } - if (!isOnline) { - store.dispatch(action); - return new Observable(observer => { - const { controller /*, signal */ } = createSignalIfSupported(); - controller.abort(); - }); + if (!Boolean(linkFetchOptions.skipOffline)) { + if (!isOnline) { + store.dispatch(action); + return new Observable(observer => { + const { controller /*, signal */ } = createSignalIfSupported(); + controller.abort(); + }); + } } // if online, we can dispatch the initial action without the .meta