# Refactoring `isLoggedIn` status in C+ - Thurs 8th Oct, 2020 Today, I finished implementing the Firebase analytics and crashylitics I've talked about in previous posts this week. One thing I need to still test is whether or not there are any problems with the build pipeline. I am adding refresh token handling (ie. when the existing access token has expired, the app should pause further API requests, ask for a new access token by sending along the refresh token, and if this is successful, resend the previous batched requests, all without requiring the user to do anything) to C+. A good place to do this in Apollo Client is in the [Error Link](https://www.apollographql.com/docs/react/api/link/apollo-link-error/). However, this presents me a problem. I currently have my `isSignedIn` value managed by an "AuthProvider" [as recommended by React Navigation themselves](https://reactnavigation.org/docs/auth-flow/#how-it-will-work). This does not work in the `errorLink` though, as it is not a React component or hook, so I cannot access this auth context. As such, I am refactoring my app's auth status to make use of Apollo Client's new [Reactive variables](https://www.apollographql.com/docs/react/local-state/reactive-variables/). This is my plan so far: ```typescript= export type AuthStatus = 'loggedIn' | 'loggedOut' | 'unknown' // "unknown" is default as there is a moment when fetching the token out of storage where we don't know if it exits or not export const authenticate = makeVar<AuthStatus>('unknown') export const cache = new InMemoryCache({ typePolicies: { Query: { fields: { authStatus: { read() { return authenticate() }, }, }, }, }, }) ``` I will detail my efforts further tomorrow. ###### tags: `programmingjournal` `2020` `C+` `auth` `reactivevariables` `apolloclient` `refreshtoken`