Updating urql cache without a mutation
Asked Answered
M

0

7

I'm working on a fullstack project that has a GraphQL backend and uses JWT for authentication. My access and refresh tokens are stored in the localStorage in the frontend.

When a user logs out, I just clear the tokens from localStorage and I further want to reset the cached query that fetches the logged user, so it returns null (meaning there is not a logged in user anymore). But, I am not excecuting a mutation. Everything is happening client-side. I can't put the mutation name in urql's cacheExchange updates object and update the cache when the mutation is excecuted.

I thought I could just add a mutation on the backend that's called logout and just returns true, but I really believe there is a more elegant way to do that.

Mcintire answered 27/1, 2022 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.