apollo-link-token-refresh
apollo-link-token-refresh copied to clipboard
Prevent forward if error
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