'How to trigger Vue Apollo Query update when skip is true?

if anyone of you using Vue Apollo please help, if I do something like this,

export default {
    apollo: {
        statsAndProfile: {
            query: STATS_AND_PROFILE_QUERY,
            update({stats, profile}) {
                this.stats = stats
                this.profile = profile
            },
            skip: localStorage.isAuth === 'false'
        },
    },
    data(){
       return {
          stats: null
          profile: null
       }
    }

}

and then in one of the components do created() { this.$apollo.queries.statsAndProfile.start() } it does not update this.stats or this.profile, update only works when skip is false from the start. Is there a way around it?



Solution 1:[1]

The query results are stored in the component's data() so you can update it directly in the body of the skip() function:

statsAndProfile: {
  skip() {
    if (localStorage.isAuth === 'false') {
      this.status = null;
      this.profile = null;
      return true;
    }
    return false;
  },
},

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 miguelr