If a user is returning to my site with existing JWT cookies I want to check if they are still valid. I think I want to preload my cache when the application loads by testing my auth token against the server.
Is this a good way/place to check if a token is still active? Yes, each call to the server will test this but I'd like to show a logged in status. Should I place a call in each component that needs to react to logged in status? Seems inefficient.
Here's what I'm thinking but it doesn't verify that the access token is still valid. Can I run a query here? What would that look like?
const client = new ApolloClient({
cache,
link,
});
cache.writeData({
data: {
isLoggedIn: !!Cookies.get('access-token'),
},
});