title: ReactQuery - useInfiniteQuery refetching issue
body: <p>I have implemented infinite scroll on a project that is using <a href="https://react-query.tanstack.com" rel="nofollow noreferrer">React Query</a> library.</p>
  <p>So far so good. Everything works as expected using the <code>useInfiniteScroll</code> hook</p>
  <p>One issue that I am encountering is the caching mechanism of this library.
  If I query for a resource, ex: GET <code>/posts/</code>, will trigger a GET <code>/posts/?page=0</code>, scroll a bit down, get the next results, GET <code>/posts/?page=1</code> which is totally fine. If I add search parameter to the page will do a GET <code>/posts/?filter=someValue&amp;page=0</code>. All fine... but when I remove the <code>filter</code> from the search it will automatically do GET <code>/posts/?page=0</code> &amp; GET <code>/posts/?page=1</code></p>
  <p>A solution is to remove the query from the cache using the <code>remove()</code> method from the query itself. But this means that I have to manually do it for each query.</p>
  <p>I would like to get a better solution that will cover all cases. I have a queryWrapper where I want to handle this.</p>
  <p>I tried using the queryClient instances <code>invalidateQueries</code> and <code>resetQueries</code> but none seems to be able to remove it from the cache...</p>
  <p><em>In the examples below I keep a <code>ref</code> for the params, if they are changed I can trigger the query to reset via <code>useLayoutEffect</code> hook. This part works as expected</em></p>
  <blockquote>
  <p>invalidateQueries attempt</p>
  </blockquote>
  <pre class="lang-js prettyprint-override"><code>queryClient.invalidateQueries(
      [queryKey, JSON.stringify(paramsRef.current)],
      {
        exact: true,
        refetchActive: false,
        refetchInactive: false
      },
      { cancelRefetch: true }
  );
  </code></pre>
  <blockquote>
  <p>resetQueries attempt</p>
  </blockquote>
  <pre class="lang-js prettyprint-override"><code>queryClient
      .resetQueries([queryKey, JSON.stringify(paramsRef.current)], {
        refetchPage: (page, index) =&gt; index === 0
      })
  </code></pre>
  <p>I even tried the <code>queryClient.clear()</code> method which should remove all existing queries from the cache but still the page number somehow remains cached... I access the queryClient using <code>useQueryClient</code> hook. If I inspect it, I can see the queries inside.</p>
  <p>Can someone please help me to sort this cache issue
  Thanks!</p>