# Cache.evict does not retrigger query

**URL:** <https://community.apollographql.com/t/cache-evict-does-not-retrigger-query/9672>\
**Category:** Client SDKs\
**Created:** [January 28, 2026, 9:33pm UTC](https://community.apollographql.com/t/cache-evict-does-not-retrigger-query/9672 "2026-01-28T21:33:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raxell](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/raxell/32/6407_2.png) [@raxell](https://community.apollographql.com/u/raxell)\
**Post date:** [January 28, 2026, 9:33pm UTC](https://community.apollographql.com/t/cache-evict-does-not-retrigger-query/9672/1 "2026-01-28T21:33:21Z")

</div>

Hi, I’m using `useBackgroundQuery` to aggregate data into a single query.  
I have a structure like the following:

```tsx
const FRAGMENT = gql`
  fragment ComponentXFragment on Query {
    myList {
      id
    }
  }
`

const ComponentX = ({ queryRef }) => {
  const { data } = useReadQuery(queryRef)

  const { data: { myList } } = useSuspenseFragment({
    fragment: FRAGMENT,
    from: data,
  })

  return <ul>{myList.map(({ id }) => <li>{id}</li>)}</ul>
}

const QUERY = gql`
  query PageQuery {
    __typename
    ...ComponentXFragment
  }
`

const Page = () => {
  const [queryRef] = useBackgroundQuery(QUERY)

  return (
    <Suspense fallback={null}>
      <ComponentX queryRef={queryRef} />
    </Suspense>
  )
}

```

Then I have another component that executes a mutation and invalidates the cache like this:

```ts
  useMutation(MUTATION, {
    update(cache) {
      cache.evict({ id: 'ROOT_QUERY', fieldName: 'myList' })
      cache.gc()
    },
  })

```

`cache.evict` correctly remove the field from the cache, but the query from `useBackgroundQuery` is not being re-executed. Using `refetchQueries` instead of `cache.evict` works.  
Does `useBackgroundQuery` only execute the request on first render and then never trigger it again? But I’ve also tried with `useQuery` and the behaviour is the same.  
How should I handle this? I don’t want to use `refetchQueries` because it requires to know every query name that uses `myList`. I just want to invalidate fields and let subscribed queries automatically refetch.

---

<div class="post-metadata">

**Author:** ![raxell](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/raxell/32/6407_2.png) [@raxell](https://community.apollographql.com/u/raxell)\
**Post date:** [January 28, 2026, 9:49pm UTC](https://community.apollographql.com/t/cache-evict-does-not-retrigger-query/9672/2 "2026-01-28T21:49:20Z")

</div>

I tried the following and it seems to work, it’s still an “imperative” refetch but I don’t need to explicitly pass the name of the queries

```ts
        client.refetchQueries({
          updateCache(cache) {
            cache.evict({ id: 'ROOT_QUERY', fieldName: 'myList' })
            cache.gc()
          },
        })

```

What’s the difference between `refetchQueries` with `updateCache` and `cache.evict`?

---

<div class="post-metadata">

**Author:** ![raxell](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/raxell/32/6407_2.png) [@raxell](https://community.apollographql.com/u/raxell)\
**Post date:** [January 31, 2026, 11:29pm UTC](https://community.apollographql.com/t/cache-evict-does-not-retrigger-query/9672/3 "2026-01-31T23:29:33Z")

</div>

> What’s the difference between `refetchQueries` with `updateCache` and `cache.evict` ?

This is still not clear to me, there are many ways to manage the cache, but it’s not clear from the doc when each method is preferable over another.  
In my view `cache.modify` is always better than `writeQuery`, `updateQuery`, etc.., as it’s not tied to a specific query structure, but is this view “correct”?

---

<div class="post-metadata">

**Author:** ![lenz](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/lenz/32/4007_2.png) [@lenz](https://community.apollographql.com/u/lenz)\
**Post date:** [February 2, 2026, 10:46am UTC](https://community.apollographql.com/t/cache-evict-does-not-retrigger-query/9672/4 "2026-02-02T10:46:54Z")

</div>

Starting from the start, if you have an active subscription (e.g. via `useReadQuery`), and that has a `fetchPolicy` of `cache-first` or `cache-and-network`, and _not_ `returnPartialData: true`, you should see a refetch.

`useSuspenseFragment`on it’s own wouldn’t cause that refetch though - maybe that might be the missing part here - I suspect you have fragment masking enabled, so the `useReadQuery` call doesn’t actually watch the value that is changing? 🤔

As for `cache.modify` vs `writeQuery`, `writeFragment` etc. - there is no clear winner. I’d usually prefer `writeFragment` or `writeQuery` because it’s just closer to how the cache interacts with GraphQL naturally, but I don’t think there is a very specific technical reason for it.
