-
App must be wrapped to
withApolloClient
hoc that adds access to graphql server -
Each time when we send request to the graphql server,
withApolloClient
hoc checks or modifies the request using special modules (Apollo links):
consoleLink
: adds information about the request to the consoleerrorLink
: checks for errors in the server response, if error is due to expired token, adds flag to the contextauthHeaderLink
: addsCookie
header to the requestrefreshTokenLink
: checks the token and updates expired or non existing tokenhttpLink
: sends each request (operation) to your GraphQL server
- GraphQL server response returns to client through all apollo links
Adds apollo client and tokens (access and refresh tokens object) to the cookies.
Use once as a wrapper for your application
Listens storage event, if one of global events (SIGN_OUT_EVENT
/SIGN_IN_EVENT
) occurs, it reloads the page
Gets user data and new pair of tokens (access and refresh) and sets them in the cookie
Just combines two auth HOC's - withTokensUpdate
and withAuthSyncEvents
Adds to page the ability to redirect from private content, if the user is not logged in
Briefly: For not logged in user and private content
Adds to page the ability to redirect from specific page, if the user is logged in, but the content of that page should not be accessible
Briefly: For logged in user and private content