Hello!
I’m implementing signing-out functionality for my app, and I’m curious if there is an elegant pattern in this area. I’m using client.resetStore()
on sign-out so that future queries do not use old data. The issue is that resetStore()
triggers all the active queries to be refetched. Immediately after sign-out, all my queries fail because the required authorization token no longer exists. I wonder if there’s a way to avoid running these queries at all, knowing that they will fail. The thing is that, in my app, the results of these queries will no longer be rendered after a sign-out, so the queries are refetched (and fail) for no reason. The behavior that I think I would want would be to clear the set of active queries: if any result of a, say, useQuery
is needed from this moment on, I want the respective query to go back to the loading state and be fetched from the server - but only if the result of a useQuery
is needed (which, in practice, I know it won’t be until a new sign-in happens).
I know that client.clearStore()
also exists, and that one does not cause active queries to be re-fetched. The problem with that one, though, is that active useQuery's
from before the clearStore()
call return old results after the clearStore()
. So that’s not good either. I guess I want something in between – I want resetStore()
to act like a barrier, but I don’t want it to eagerly refetch anything.
Does this make any sense / am I missing something?
Thanks a lot!