Apollo-client: 0.5.22 breaks refetchQueries, reducer, updateQueries

Created on 5 Jan 2017  路  13Comments  路  Source: apollographql/apollo-client

I have a pretty basic setup where I am on an 'overview' page, I click a 'create' button which navigates to another page where I can then fill out a form, submit it, and return to the overview page where the submitted item should be reflected.

The submission is a mutation and was using refetchQueries to reload the query loading the overview page. This has recently stopped working.

Checking various versions, it last worked in 0.5.21 and broke in 0.5.22, which seems to have involved changing related functionality.

Basically anywhere in my app using refetchQueries now does nothing and results in stale state.

Is anyone else seeing similar issues?

馃毃 high-priority

Most helpful comment

We're running into the same issue and had to lock our version at 0.5.21 until it's resolved.

All 13 comments

@mmmdreg Thanks for the bug report! I think this is due to the same change that was mentioned in #1085. The gist of it is that inactive queries now get removed from the store, so their reducer functions no longer run, and they also no longer get refetched unless they are active at that time. It turns out that what I thought was just fixing a bug turned out to also disable a behavior that a lot of people depended on.

We'll make this a priority to provide a better solution for updating the cache. Expect to see some activity in that direction early next week!

clarification: In addition refetchQueries this issue also affects updateQueries and the reducer option to watchQuery.

update (Jan 22, 2017): We've come up with a design that we think is workable and start implementing it this week.

@helfer

The gist of it is that inactive queries now get removed from the store, so their reducer functions no longer run, and they also no longer get refetched unless they are active at that time. It turns out that what I thought was just fixing a bug turned out to also disable a behavior that a lot of people depended on.

Is this why updateQueries stopped working all over my app (doesn't update anything) when I upgraded from 0.5.6 to 0.5.25? If so, what the best action to take to keep things working? Will this be fixed in a later release, or is there a particular way I should be rewriting my updateQueries?

@booboothefool yes, most likely sorry. If I knew that more people ran into this issue, I would have deprecated 0.5.22 and released it again as 0.6. Unfortunately only one person filed an issue or said anything, so it seemed okay to just keep things as they were since it was considered a bug fix.

I will get on this asap.

We're running into the same issue and had to lock our version at 0.5.21 until it's resolved.

@helfer ran into the same issue as well

Hey all,

I know that the issue is being discussed in #1224, but does a workaround exist for this? The application that my team and I are developing, heavily relies on this feature.

Best regards,

Michael

The current workaround seems to be to downgrade to 0.5.21 :)

@marktani yes, unfortunately we then run into this issue again https://github.com/apollographql/apollo-client/issues/993

@mlukaszczyk you could not unsubscribe from queries you still may want to update. For React this means not unmounting components with queries you want to update.

@mlukaszczyk @marktani I've set forceFetch in query options and it works fine.)

@calebmer's new PR over here: apollographql/react-apollo#462 solved all of my outstanding issues. I would recommend that people pull the change locally and give it a test.

Thanks for the heads up @Siyfion :+1:

I'll close this for now.

Was this page helpful?
0 / 5 - 0 ratings