Infinite loading on failed query with Vue apollo

300 views Asked by At

I'm developing an app with Quasar, it compiles to Cordova app so I can run it on my phone. The weird thing is that I have that error only on my phone, without errors in console and only on the first load when app was installed.

I have a simple query

  apollo: {
    receipts: {
      query: GET_RECEIPTS,
      loadingKey: "loading",
    },
  },

and my component data is:

  loading = 0;

  @Watch("loading")
  emitLoading(val) {
    this.$apollo.mutate({
      mutation: UPDATE_LOADING,
      variables: { loading: !!val }
    });
  }

But the thing is when query cannot fetch anything (no data in DB), I get infinite loading. Should I fix with apollo error hook? And if yes how do I access loading data for the hook?

1

There are 1 answers

0
Dvdgld On BEST ANSWER

The solution wasn't obvious at all. I needed to change my route path for that page (homeManagement). Previously I had:

path: "/",
component: () => import("layouts/main-layout.vue"),
meta: { requiresAuth: true },
children: [
  {
    path: "",
    name: "homeManagement",
    component: () => import("pages/home-management/index.vue")
  }

And now I have:

path: "/",
component: () => import("layouts/main-layout.vue"),
meta: { requiresAuth: true },
children: [
  {
    path: "home",
    name: "homeManagement",
    component: () => import("pages/home-management/index.vue")
  }

I didn't figured out why is that. And btw path: "/" for homeManagement also gives me that issue with loading.