-
-
Notifications
You must be signed in to change notification settings - Fork 522
Description
Describe the bug
A smart query added via the apollo
option does no longer update the rendered data when the cache is updated whilst the update does happen with this.$apollo.addSmartQuery
.
To Reproduce
- With the vue options api add a smart query returning an array of results with
apollo: {
mykey: MyQuery,
},
data() {
return {
mykey: [],
};
},
- Update the cached data of this query.
Expected behavior
Data is rendered and the rendered data updates according to the updated data in the cache.
Actual behavior
Whilst the initial server result is rendered, no updates to the cache are rendered.
Note that it seems like the new data is picked up by the query and forwarded to the vue component: Printing the current content of this.mykey
to the console within a setInterval
shows, that the component's state is updated, but seemingly in a non-reactive way as the rendered state of the component does not change.
Workaround
Manually adding the smart query works: Replacing the apollo
option with
created() {
this.$apollo.addSmartQuery("mykey", {
query: MyQuery,
});
},
solves the issue; the rendered data is updated as expected. This is not what I expected; I thought, this would do the exact same thing, but it does not.
Versions
vue: 3.2.33
vue-apollo: 4.0.0-alpha.16
@apollo/client: 3.5.10
Additional context
The bug appeared somewhere in between vue version 3.2.29 (everything working as expected) and vue 3.2.33 (described behavior).