Refetch no longer works in 3.5 when skip is true
See original GitHub issueHello. 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:
- Created 2 years ago
- Reactions:8
- Comments:16 (4 by maintainers)
Top GitHub Comments
My opinion is that
refetch
should always execute regardless ofskip
. This change broke our application.In any case dont we consider this a breaking change? If so this is not according to semver IMHO.