# Skipped Query returns old data after cache clearing

**URL:** <https://community.apollographql.com/t/skipped-query-returns-old-data-after-cache-clearing/7416>\
**Category:** Client SDKs\
**Tags:** client, web\
**Created:** [April 23, 2024, 12:11pm UTC](https://community.apollographql.com/t/skipped-query-returns-old-data-after-cache-clearing/7416 "2024-04-23T12:11:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MardanovaA](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/mardanovaa/32/5044_2.png) [@MardanovaA](https://community.apollographql.com/u/MardanovaA)\
**Post date:** [April 23, 2024, 12:11pm UTC](https://community.apollographql.com/t/skipped-query-returns-old-data-after-cache-clearing/7416/1 "2024-04-23T12:11:17Z")

</div>

I have query to get user data (roles, username)

```auto
   const token = getCookie(CookieNames.TOKEN);
   const { data, refetch, loading } = useUserGetCurrentQuery({
     skip: !token,
   });

```

Also I have storeClearing on logout

```auto
export const logout = async () => {
  const apolloClient = initializeApollo();

  removeCookie(CookieNames.TOKEN);
  localStorage.deleteItem('refreshToken');

  logoutEvent();

  await apolloClient.clearStore();
  await redirect({ route: routes.AUTH });
};

```

After cache clearing on auth page we call getUserData hook. As token is empty I expected, what query will skipped and data would be undefined. But it still returns old data, cache is clear though.

Any help please, I blew my mind 🤯

---

<div class="post-metadata">

**Author:** ![MardanovaA](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/mardanovaa/32/5044_2.png) [@MardanovaA](https://community.apollographql.com/u/MardanovaA)\
**Post date:** [April 24, 2024, 6:42am UTC](https://community.apollographql.com/t/skipped-query-returns-old-data-after-cache-clearing/7416/2 "2024-04-24T06:42:54Z")

</div>

Answer from [issue with this problem](https://github.com/apollographql/apollo-client/issues/11804):

> If your hook was mounted all that time, that is possible.
> 
> Generally, cache updates are forwarded to the hooks, but skipping a hook also means skipping any updates from the cache - including a cache reset.
> 
> If the component with that hook would be unmounted and remounted, it would start with a blank state, but since it seems to stay mounted in your case, the moment you “un-skip”, it will pick back up with the last state it had and wait for future cache updates.

Looks like intended behavior. I clear cache, and then call query with skip: true. Apollo can’t get new data, so it returns the last one it has.  
Further discussion will be in issue
