apollo-link-token-refresh icon indicating copy to clipboard operation
apollo-link-token-refresh copied to clipboard

Prevent forward if error

Open TheNerdGuyLulu opened this issue 2 years ago • 0 comments

Context: If the refresh token has expired, it will trigger handleError. Inside, this condition confirms that the refresh token has expired and calls logout, clearing sessions local cache.

// If the refresh token expired, log the user out 
if (err.message === 'Unknown or invalid refresh token.') {
  await logout();
}


// Links
link: from([errorLink, refreshLink, authLink, httpLink]),

This will trigger a new request, which will fail since the token couldn't be refreshed. If we could manually call forward, or just return a boolean (true forward, false terminate), it would give the developer more power to control the error handle.

If there's another way to accomplish this, please let me know. Thank you

TheNerdGuyLulu avatar Jul 11 '22 17:07 TheNerdGuyLulu