nuxt-modules / apollo

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

useQuery throws error if clientId supplied #620

Open veerendrapatel opened 1 month ago

veerendrapatel commented 1 month ago

Environment

Describe the bug

I have multiple graphql client configured. If I use useAsyncQuery supplying clientId it works const res = await useAsyncQuery(GET_EVENT(evParam), "cmsApollo");

If I use useQuery supplying clientId I get error - Error: No apolloClients injection found, tried to resolve 'cmsApollo' clientId

const res = useQuery( GET_EVENT(evParam), {}, { clientId: "cmsApollo" } ); Error: No apolloClients injection found, tried to resolve 'cmsApollo' clientId

Expected behaviour

useQuery should work with clientId

Reproduction

No response

Additional context

No response

Logs

No response

veerendrapatel commented 1 month ago

@Diizzayy Both URLs point to the same GitHub repository but diff steps to configure client. https://nuxt.com/modules/apollo https://apollo.nuxtjs.org/getting-started/quick-start https://github.com/Diizzayy/nuxt-graphql-client Question: Which one is recommended for a MultiClient setup? I followed this quick start guide, and it works with "@vue/apollo-composable": "4.0.0-beta.12". While useAsyncQuery works, useQuery does not, which is discussed in this GitHub issue. However, when I upgraded from Nuxt 3.7 to 3.11, useAsyncQuery stopped working. The following code throws an error for the supplied client ID cmsApollo: const res = await useAsyncQuery(GET_ACCOUNT(accParam), "cmsApollo"); Please provide your input on which approach I should follow to ensure smooth future upgrades of Nuxt.