Skip to content

Apollo Option does not update data reactively #1350

@Steditor

Description

@Steditor

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

  1. With the vue options api add a smart query returning an array of results with
apollo: {
   mykey: MyQuery,
},
data() {
  return {
    mykey: [],
  };
},
  1. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions