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

updateQueries not trigger at version 0.5.24 #1084

Closed
luckyyang opened this issue Dec 23, 2016 · 6 comments
Closed

updateQueries not trigger at version 0.5.24 #1084

luckyyang opened this issue Dec 23, 2016 · 6 comments
Labels

Comments

@luckyyang
Copy link

luckyyang commented Dec 23, 2016

same code will trigger updateQueries at version 0.5.20, not at version 0.5.24

attach my code:

// graphqlModule/updateQueries/providerList.js

export const providerList = {
  userList: (prev, { mutationResult }) => {
    const result = mutationResult.data.registerWithIdentification

    return update(prev, {
      userList: {
        data: {
          $unshift: [result]
        }
      }
    })
  },
}

======

// container.js

import { providerList as updateQueries } from 'graphqlModule/updateQueries/providerList'

  async submit() {
        const res = await mutate({ variables, updateQueries })
  }
@helfer
Copy link
Contributor

helfer commented Dec 23, 2016

Is this the same as #1085?

The explanation is that we now remove old queries and their update functions from the store. I considered this a bugfix, so it was released as a patch. The consequence of the bugfix is that updateQueries only runs for queries that have an active observer. Admittedly, that's not flexible enough, so we'll have to come up with a different solution to update the cache even when a query isn't active any more.

@luckyyang
Copy link
Author

They are different issues:

@adambard
Copy link

adambard commented Jan 5, 2017

I'm going to go ahead and +1 this guy -- for my codebase at least this was definitely a breaking change (an SPA using react-apollo), I had to go back to forceRefetch-ing. Does apollo-client/react-apollo presently provide a way to update/cache-bust a query associated with a component that is not presently mounted?

@zth
Copy link

zth commented Jan 6, 2017

I have the same issue, I am unable to access neither updateQueries nor reducer on queries that aren't presently mounted. Is this intended? I don't see how I'd be able to update my other queries now, since they belong to different routes (which means they'll need to be unmounted when not active). I use forceRefetch right now as well, but it's a rather expensive and entirely unnecessary query that gets run now as it fetches data that hasn't changed other than the addition that I'd be able to update manually through updateQueries.

Any clues/thoughts on how we can mitigate this? Thanks!

@zth
Copy link

zth commented Jan 8, 2017

I can confirm this works for me when I downgrade to 0.5.21. I'll just remain at that version for now, I saw this issue was brought up in another issue as well :)

@luckyyang luckyyang changed the title updateQueries not trigger at version 2.5.24 updateQueries not trigger at version 0.5.24 Jan 27, 2017
@helfer
Copy link
Contributor

helfer commented Feb 2, 2017

I'm going to close this here so we can track it in #1129, which was filed first. We're discussing the best design to solve this in #1224.

@helfer helfer closed this as completed Feb 2, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants