Composition-api: fix: @vue/apollo-composable, query in pending

Created on 21 Jul 2020  ·  7Comments  ·  Source: nuxt-community/composition-api

Hello,

🐛 The bug
@vue/apollo-composable is not working. The query is in pending.

🛠️ To reproduce
The easiest way is to checkout my repo:
https://github.com/shenron/vue-nuxt-tsx

🌈 Expected behaviour
The query is in pending on the last version of nuxt-composition-api@^0.10.6 but works on "^0.8.2"

ℹ️ Additional context
I used this workaround:
https://github.com/nuxt-community/apollo-module/issues/288#issuecomment-581244070

Thank you for your help!

bug

All 7 comments

@tcastelly Could you try using onGlobalSetup to provide the client?

https://composition-api.now.sh/helpers/onGlobalSetup.html

I tried like this:

import { provide, onGlobalSetup } from 'nuxt-composition-api';
import { DefaultApolloClient } from '@vue/apollo-composable';

export default ({ app }) => {
  onGlobalSetup(() => {
    const apolloClient = app.apolloProvider.defaultClient;

    provide(DefaultApolloClient, apolloClient);
  });
};

Same behavior, but maybe I did not used as expected ...

@tcastelly I've looked at your repo and indeed all is as you describe.

However, it does not seem to be an issue with nuxt-composition-api. When I replace all references to this library with @vue/composition-api, the same behaviour can be observed. This suggests that the issue is the upgrade of @vue/composition-api from ^0.5.0 to 0.6.7. I would recommend creating an issue there - or possibly with https://github.com/vuejs/vue-apollo/.

I've not looked into it, but a prickle on the back of my neck suggests it might be the changed behaviour with watch (which now defaults to lazy execution), and thus an easy fix within Vue Apollo.

I guess it's linked to this issue:
https://github.com/vuejs/vue-apollo/issues/1009

It's has been fixed. Thank you for your time!

@tcastelly Great!

Was this page helpful?
0 / 5 - 0 ratings