Skip to content

Instantly share code, notes, and snippets.

@ashhitch
Forked from alfonmga/apollo-refreshToken-link.js
Created September 5, 2019 20:27
Show Gist options
  • Save ashhitch/a6fc9a0b877c36c968a257d3eb9ba584 to your computer and use it in GitHub Desktop.
Save ashhitch/a6fc9a0b877c36c968a257d3eb9ba584 to your computer and use it in GitHub Desktop.
Apollo refresh auth token link. It tries to refresh user access token on the fly when API throws out an UNAUTHENTICATED error. If multiple requests fails at the same time it queues them to re-try them later if we are able to get a new access token, otherwise we logout the user and redirect him to the login page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment