question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refetch no longer works in 3.5 when skip is true

See original GitHub issue

Hello. I’ve been using refetch from useQuery for over a year. In my code, I use it in combination with skip: true to fetch queries lazily. Starting from 3.5 (worked in 3.4), I can no longer do that. My browser doesn’t run the query as expected with the following code:

import { Query } from './something.graphql';

const Test = () => {
    const variables = { ... };
    const { refetch } = useQuery(Query, {
        skip: true,
        variables,
    });
    const click = async () => {
        const response = await refetch();
        console.log('response', response);
    };

    return <button onClick={() => click()}>Refetch</button>;
};

Intended outcome: A network request would be made for the query, and response would include the results of that.

Actual outcome: No query is made andresponse is undefined.

How to reproduce the issue: Code above. I’m assuming this might have to do with skip: true, but again this worked < 3.5.

Versions System: OS: macOS 11.6 Binaries: Node: 17.0.1 - /usr/local/bin/node npm: 8.1.0 - /usr/local/bin/npm Browsers: Chrome: 95.0.4638.69 Safari: 15.1 npmPackages: @apollo/client: ^3.3.21 => 3.5.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
cjreimercommented, Dec 9, 2021

My opinion is that refetch should always execute regardless of skip. This change broke our application.

7reactions
JensMadsencommented, Dec 8, 2021

In any case dont we consider this a breaking change? If so this is not according to semver IMHO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refetching queries in Apollo Client - Apollo GraphQL Docs
If onQueryUpdated is not provided, the default implementation returns the result of calling observableQuery.refetch() . When onQueryUpdated is provided, it can ...
Read more >
@apollo/client - Awesome JS
Fix issue where loading remains true after observer.refetch is called repeatedly with different variables when the same data are returned. @alessbell in #10143....
Read more >
React Apollo: Understanding Fetch Policy with useQuery
A cache-only query throws an error if the cache does not contain data for all requested fields. cache-and-network, Apollo Client executes the ...
Read more >
Documentation: 15: SELECT - PostgreSQL
SELECT retrieves rows from zero or more tables. ... Both the SEARCH and the CYCLE clause are only valid for recursive WITH queries....
Read more >
Apollo client refetch - OCentrum.pl
fullData: Raw data returned by the query (not transformed by the update prop) ... bureau phone number Refetch no longer works in 3.5...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found