DEV Community

Discussion on: vue/vuex - confused about when to load state

Collapse
 
daradedesign profile image
Dallas DeGrendel

So it sounds like you are torn between two hack fixes. Loading everything always seems more viable when data is the bare minimum and served from the same computer. Unless you are building a PWA and that is essential data, this is a lazy move, and you learn nothing.
You said these queries are supposed to fire on page change. Are the staying on the same page, but the id is changed, or are you changing pages completely?
How are you triggering the query?

Are you reloading because you only query when the component is created...

created() {
    if (this.location) {
      this.$apollo.queries.locationById.skip = true;
    }

I just took a quick peek. Also, it might be better to use a getter to maintain your state.
Honestly, if you are new to vue and vuex, I would scaled down a bit. You will probably need help again, and that's page code length is going to be tough to jump into cold.

Collapse
 
danroc profile image
Daniel da Rocha

Thanks for the reply... it is a bit too late though ;)

I am now totally into GraphQL and Vue Apollo, where the queries are tightly coupled with the components which need them, and the Apollo Cache makes store and request control quite intuitive.