React-apollo: [2.0] variables are not working with cached data

Created on 3 Oct 2017  路  8Comments  路  Source: apollographql/react-apollo

I have component which is used with react-router.

@graphql(PROFILE_CONTAINER_QUERY, {
  options: ({ match: { params: { username } } }) => ({
    variables: {
      username,
    },
  }),
})

Everything works fine until I will click on back button in the browser.

I can see that my component is rerendered but I can see old data from previous page. Variable username has correct value but react-apollo is using old variable.

    "apollo-cache-inmemory": "^0.2.0-beta.3",
    "apollo-client": "^2.0.0-beta.3",
    "apollo-fetch": "^0.6.0",
    "apollo-link-batch-http": "^0.2.1-beta.6",
    "apollo-link-http": "^0.6.1-beta.6",
    "react-apollo": "^2.0.0-beta.0",`

Most helpful comment

Also having trouble with this.

All 8 comments

same issue. data changes after a request response but when returning to a previous set of variables, data doesn't change.

@seeden I revert apollo-client to 2.0.0-beta.2 as a temp fix. Is it the same for you ?

Reverting to apollo-client to 2.0.0-beta.2 did not resolve the issue for me.

This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!

It still doesn't work!

Also having trouble with this.

Not 100% sure its from the same cause, but this sounds very similar to some behavior I'm seeing where cached variables seem to be getting passed into my query even though they're correct going into the fetch. I've tried it with network-only as a fetch policy and that doesn't seem to matter. It seems to kick in when a query returns an empty collection for a list return type (i.e. if my query returns a list of people, after a query returns an empty list I start seeing the cached arguments going into queries.)

This should no longer be an issue with current versions of React Apollo. Thanks!

Was this page helpful?
0 / 5 - 0 ratings