nuxt-modules / apollo

Nuxt.js module to use Vue-Apollo. The Apollo integration for GraphQL.
https://apollo.nuxtjs.org
MIT License
945 stars 199 forks source link

Can't use apollo composables when @vue/apollo-composable isn't directly inside node_modules #519

Closed oosame closed 7 months ago

oosame commented 1 year ago

Environment

Describe the bug

using useLazyAsyncQuery or any of the other apollo composable but useAsyncQuery results in the following import bug

[plugin:vite:import-analysis] Failed to resolve import "@vue/apollo-composable" from "pages/sink.vue". Does the file exist?

image

Expected behaviour

I should be able to use the other composables according to the docs, right?

Reproduction

No response

Additional context

No response

Logs

No response

zenflow commented 1 year ago

I have the same issue. It was working fine until I installed GraphQL Code Generator.. This changed the dependency tree so that the @vue/apollo-composable package was no longer at ./node_modules/@vue/apollo-composable (where this package expects it to be) and was moved to ./node_modules/@nuxtjs/apollo/node_modules/@vue/apollo-composable.

This package needs to resolve the location of @vue/apollo-composable according to the node module resolution algorithm, instead of assuming it to be directly inside node_modules.

@oosame Could you maybe update the issue title to be more accurate? (Since sometimes you can use apollo composables). Something like "Can't use apollo composables when @vue/apollo-composable isn't directly inside node_modules?

oosame commented 1 year ago

@Diizzayy could you kindly give us a hand?

AlexanderBredun commented 1 year ago

any updates on this? i have same error

zenflow commented 7 months ago

@Diizzayy did you link this issue accidentally? This has nothing to do with reactivity or type hints and all to do with module resolution. Thanks!

Diizzayy commented 7 months ago

@zenflow no, there have been slight changes which has thus far proven to fix this issue, hence why it has been closed until further notice ( will be revisited if needed )

zenflow commented 7 months ago

Great news @Diizzayy thank you!!