Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactive Variables with 'cache-first' not working in new version #138

Closed
gijo-varghese opened this issue Oct 30, 2017 · 17 comments
Closed

Comments

@gijo-varghese
Copy link

gijo-varghese commented Oct 30, 2017

I recently upgraded to the latest client 2.0. But after that reactive queries are not working. However, this is the case only for cache-first. For network-only its working. I think there is a bug in the new version. Looks like it can't read from cache

@gijo-varghese gijo-varghese changed the title Reactive Variables with 'cache first' not working Reactive Variables with 'cache-first' not working in new version Nov 2, 2017
@gijo-varghese gijo-varghese reopened this Nov 2, 2017
@gijo-varghese
Copy link
Author

gijo-varghese commented Nov 2, 2017

@Akryum I think its a bug with the latest version, v2.

The query below was working fine. But after upgrading, it's not working anymore

apollo: {
    user: {
      query: USER,
      variables() {
        return {
          id: this.$route.params.user_id
        }
      },
      fetchPolicy: 'cache-first' // If I change it to 'network-only' its works. But using devtools I found that the required data is already in cache
    }
  }

@Akryum
Copy link
Member

Akryum commented Nov 2, 2017

Do you have a reproduction to share?

@gijo-varghese
Copy link
Author

@Akryum mine is a little big code base and it's in localhost. So have to host 3 projects in order to show it to you

@Akryum
Copy link
Member

Akryum commented Nov 2, 2017

Well, you don't have to share your entire project, but if you can, it would be great to have a minimal reproduction of the issue in a separate repository (or zip).

@gijo-varghese
Copy link
Author

@Akryum ok. I'll create a simple repo and send it to you soon

@gijo-varghese
Copy link
Author

@Akryum I've created for you: https://github.com/gijo-varghese/vue-apollo-demo
The master branch is with Apollo Client v1: Works Perfectly
The apollo-client-v2 is with Apollo Client v2: Not working as expected.

@gijo-varghese
Copy link
Author

@Akryum are you able to reproduce it? I'm using a sample API developed by Graph Cool. Not sure how long will they exists

@Akryum
Copy link
Member

Akryum commented Nov 4, 2017 via email

@gijo-varghese
Copy link
Author

@Akryum can you please check it

@thomasaull
Copy link

I got the same problem, any updates on this?

@gijo-varghese
Copy link
Author

@thomasaull try updating your packages. It's working for me now

@thomasaull
Copy link

thomasaull commented Jan 19, 2018

@gijo-varghese No, unfortunately it doesn't solve the issue for me… I got an array of ids I want to filter my data with:

// Add 2: Works
const ids = [2]

// Add 5: Works
const ids = [2, 5]

// Remove 5: Doesn't work, my view doesn't get updates
const ids = [2]

This is only true if I use fetchPolicy: 'cache-first' which is the default afaik. If I change it to cache-and-network it does work, but it needs another request of data, which is already present…

@gijo-varghese
Copy link
Author

Can you pls provide a link to the repo? I'll check it

@gijo-varghese
Copy link
Author

Or try my repo: https://github.com/gijo-varghese/vue-apollo-demo (there is a branch with Apollo client v2)

@thomasaull
Copy link

thomasaull commented Jan 20, 2018

I tried to create a test repo yesterday, but I couldn't reproduce the error… Queries in Apollo Dev Tools get updated accordingly, just the data doesn't show up in my component

@cnoter
Copy link

cnoter commented May 27, 2019

I think this is not an error.
my recommendation is this.

you need to make separate queries for both type.
one, not-using reactive variable query.
the other one, using reactive variable query.

then, with the second type of query, you need specify in apollo inmemory-cache's option
about how do you want characterize that type of query's dataIdFromObject.

for example:
__typename + id + 'reactive var'

then, you can using apollo cache as you want.

@gijo-varghese
Copy link
Author

I left VueJS though 😐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants