apollo-client: skip option fails when assigned a variable that flips from false to true

Intended outcome:

skip: true results in no network request. The error property in the result of the useQuery hook reflects the current running query.

Actual outcome: skip: true results in a network request. The error property displays for the previous result.

How to reproduce the issue:

  1. Go here: https://codesandbox.io/s/apolloclient-v3-skip-bug-ov1z3?file=/src/app.js
  2. Click the button and observe the 400 from the graphql endpoint.
  3. Click the button again and observe the successful response but the logged error message.

Image from Gyazo

Versions Image from Gyazo

Related Issues https://github.com/apollographql/apollo-client/issues/6190 https://github.com/apollographql/apollo-client/issues/6572 https://github.com/apollographql/apollo-client/issues/6507

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 19 (2 by maintainers)

Commits related to this issue

Most upvoted comments

We’re finalizing a fix for this and other skip related issues, and should have it ready today.

i’m surprised the major release (out of beta) was done with this still broken (since it was a known thing not a bug that popped after release)… it’s a pretty widely used feature and I was a little shocked after I migrated to find the console error and this thread … would of been nice if it was a known thing to make mention of it in the release/migration guide … maybe its just me though?

@3nvi is there any other things I should keep an eye on based on your comment sounds like there might be other unmentioned issues? … we’ve been QA’ing the migration to 3.0.2 but a heads up if you know of anything specific would be great!

https://github.com/apollographql/apollo-client/issues/6603 https://github.com/apollographql/apollo-client/issues/6644 https://github.com/apollographql/apollo-client/issues/6636 (fixed in upcoming 3.1.0.)

@hwillson I’ll give it a check after my morning meetings. Can you give me about two hours? If you publish pre’s to npm you could also check the sandbox quickly, I believe.

Edit: Looks like you guys do, and looks like it did fix the issue in the sandbox. As discussed on the PR, data is being returned now when skip: true, but at least no network request is made.

Funnily enough we migrated back to beta-43. It’s more stable as of the moment of writing

@benjamn I’d like to learn more about the inner-workings of ApolloClient, and would be happy to try and fix this but I’m not sure what I’m looking for. I know the options are differing here, with skip: true being in the new options:

https://github.com/apollographql/apollo-client/blob/7993a778ef5a9e61bfee72b956f4c179fce691f4/src/react/data/QueryData.ts#L241-L255

which calls to update the “current observable” on the query data class. I’m guessing that for some reason the thing that makes fetch/no-fetch decisions is not aware of this update.