fix: stop flickering due to late initiated token
This commit is contained in:
@@ -13,7 +13,7 @@ const client = new ApolloClient({
|
||||
link: createLink({ uri: appConfig.graphqlUrl })
|
||||
});
|
||||
|
||||
export function setLink(options: CreateClientOptions): typeof client {
|
||||
export function mutateAndGetClient(options: CreateClientOptions): typeof client {
|
||||
const { onError, token } = options;
|
||||
const link = createLink({ uri: appConfig.graphqlUrl, token, onError });
|
||||
|
||||
|
@@ -2,6 +2,7 @@ import { HttpLink, from } from '@apollo/client';
|
||||
import type { ApolloLink } from '@apollo/client';
|
||||
import { onError } from '@apollo/client/link/error';
|
||||
|
||||
import { setItem } from 'helpers/storage';
|
||||
import * as URLS from 'config/urls';
|
||||
|
||||
type CreateLinkOptions = {
|
||||
@@ -29,6 +30,7 @@ const createErrorLink = (callback: CreateLinkOptions['onError']): ApolloLink =>
|
||||
);
|
||||
|
||||
if (message === NOT_AUTHORISED) {
|
||||
setItem('token', '');
|
||||
window.location.href = URLS.LOGIN;
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user