apollographql / apollo-link

:link: Interface for fetching and modifying control flow of GraphQL requests
https://www.apollographql.com/docs/link/
MIT License
1.44k stars 344 forks source link

Suggestion (apollo-link-retry) notify errors #455

Open LarsKrogJensen opened 6 years ago

LarsKrogJensen commented 6 years ago

When the retry-links an error it silently continues to poll without notifying in any way, the UI is thus unaware it is potentially is displaying out-of-date information.

A suggestion is to inform that an error has occurred and continue to poll.

pennyandsean commented 6 years ago

Maybe you could you hook retryIf:

const retryLink = new RetryLink({
  delay: {
    initial: 500,
    max: Infinity,
    jitter: true
  },
  attempts: {
    max: 5,
    retryIf: (error, _operation) => {
      console.log("Retrying ...");
      return !!error;
    }
  }
});

With a reference to the retryLink instance, you can assign new retryIf and delayFor functions on the fly.

mathiastambjergsteengaard commented 5 years ago

Maybe adding some callbacks would be the best way to go. onFirstRetry, onReconnect, onLastFailedAttempt. Or maybe an onRetry passing the retry count to the callback. In this way the implementation of the error notifications is separated from the lib