-
Notifications
You must be signed in to change notification settings - Fork 786
"Skip" property of useQuery hook has no effect #3492
Comments
Same issue here, when setting skip to true, the query is still executed |
Would one of you be able to provide a small runnable reproduction for this? Thanks! |
@hwillson I just tried a really simple version in codesandbox and it works fine. It could be related to the fact that im using an AWS-appsync client instead of an apollo-client. So im hesitant to post my exact code. here is the sandbox of it working anyway https://codesandbox.io/embed/funny-field-1oeyk maybe @limekiln can provide his set up if its more inline with a regular apollo setup |
+1, I am still having this issue. |
This is still an issue for me too, and I am using "@apollo/react-hooks": "^3.1.3" All you need to do is use |
I can confirm I have the same issue. "@apollo/react-hooks": "^3.1.2" |
Sorry for the late reply and not supplying a code example. For my current version setup, everything related to the System:
|
Still having this issue with:
|
Hello, |
@imeugenia which version of |
@imeugenia @FacundoGFlores I'm also having this issue. Perhaps it's a bug in 3.1.3 since that's the same version I'm using. Using "react-apollo" doesn't fix the issue for me either. |
The issue exists with |
@trdaya I'm actually trying to use it for a query with the default fetchPolicy, and it's not working. Version 3.1.3 as I mentioned earlier |
I'm on 3.1.5 and also experiencing the same problem. Have tried changing fetchPolicy from cache-and-network to network-only as well as making sure the import is from react-apollo. |
I'm bumping into this after Curious if the query refetch logic that is run on store reset doesn't contain the necessary logic to obey the |
In
This did fix the error I was bumping into. I couldn't figure out where this change should go ( |
I'm facing the same error. I am also getting a network error 400: "variable $jwt of non-null type String! must not be null." |
Yes, I'm hitting the same on
@derLalla Agree 😒 |
I am facing the same issue on |
same problem with @apollo/client: 3.0.0-beta.50 |
Same problem with |
If i set skip to true - it works, but if i use dynamic variable skip: !state.startDate it's not |
I'm using Use cases:
Small runnable reproduction:https://codesandbox.io/s/skip-does-not-work-rx2rj?file=/src/App.js I have an array of currencies, and I only want to fetch the currencies which indexes are odd. ExpectedOnly queries for odd indexes should trigger an HTTP request. ActualAfter setting the variable to ScreenshotsRunning USD is even, so it skips, and Unfortunately, Apollo triggers an HTTP request anyway, independent of The only one it respects is the first time I pass |
No news on this? We still have this issue in the latest RC9, are forced to use a pre-beta.50 version. |
It actually broke in 3.0.0-beta.46. Last working release is 3.0.0-beta.45! |
No updates on this? Is there a workaround? The following workaround suggested in #6190 doesn't work for us since we need to use
|
Two other issues regarding skip are tracked in the apollo-client repo for the 3.0 milestone, e.g.: |
@Taraluktus Thanks for the response. If that's the case, this issue should be closed, and that other issue should encompass the client-side problem as well, and be referenced here as the canonical issue. |
For those like me... According to @apollo/client tests, So for me, where I was doing:
...the query was still made, and that is intended, |
There are two wrong assumptions here:
This is a big issue and people logged it in many different repos, and the Apollo team should at least give us a response. I tried to debug their code to come up with a PR, but it's too deep, hard to grasp, so I can't help if there aren't any guidelines. For now, I'm just using a hack to work-around the bug. |
I see @buzinas, I didn't see that And I fully agree, this shouldn't require looking in the the tests, I just wanted to help out those that were hit and running this thread. |
In my case, I was able to get const { data: { testList = [] } = {} } = useQuery(
GET_TEST_LIST,
{
skip: !shouldQueryExecute,
variables: { session: shouldQueryExecute && session },
}
) As soon as I remove the condition for the variable Hope this helps anybody with a similar use case. |
@caycecollins changing the CodeSandbox example to something similar to what you suggested still doesn't work for me. |
@buzinas I simplified yours to be closer to mine in this CodeSandbox, but it seems that My project has an AuthLink and ErrorLInk setup, and my component has several other query and mutation hooks, uses of useState and useEffect hooks, and other components which query the same data as well... so I'll keep digging but in my specific case, adding a condition to the passed variable |
@caycecollins Your example is exactly the opposite of the one that doesn't work. You're starting |
@buzinas sorry if that was misleading or confusing. The sandbox I made was an attempt to show the issue I was experiencing with my case, but it seems to work fine in CodeSandbox (which means something else is at play in my case). When the component loads, My issue is the same as the issue author, where |
I use this to prevent network request: fetchPolicy: isSkip ? : 'cache-only' : 'cache-and-network' It's a walk around though. Hope this issue can be fixed. |
This is an issue for us as will, the |
Seeing this on @apollo/client 3.0.0 / 3.0.1 on the client side also. For me it makes no difference if Interestingly as others have noted, if you have no variables, or variables set to |
This is issue persist in the version of |
A workaround that I am currently using for this is using useEffect with a lazy query. const [myLazyQuery, { loading, error, data}] = useMyLazyQuery()
useEffect(() => {
if(var1) {
myLazyQuery({
variables: { var1 }
})
}
}, [var1, myLazyQuery]) |
Intended outcome:
Using the
skip
property ofuseQuery
, I expect the query not to be executed as long asskip === true
.Actual outcome:
No matter which value
skip
has, the query is always executed.Version
System:
The text was updated successfully, but these errors were encountered: