Replies: 2 comments 7 replies
-
Could you try |
Beta Was this translation helpful? Give feedback.
-
Hi @fabis94 , I'm still running Nuxt 2.17.x because of several dependancies that were not migrated over Nuxt3. I recently had to get rid of @nuxtjs/apollo and found @apollo/client, @vue/apollo-option as a replacement. I'm running in the same kind of issues. I did a force install of @vue/apollo-option 4.0.0. So far, I'm able to inject the "apolloProvider" via a Nuxt plugin, however the "apollo" option does not work. So I thought of doing a Vue.use(...) but ran into the issue you mentioned. I've tried (but this doesn't work): const apolloProvider = createApolloProvider(...)
Vue.config.globalProperties = Vue.config.globalProperties || {}
Vue.prototype.$apolloProvider = apolloProvider
apolloProvider.install(Vue) Below is my current implementation via Inject: import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client/core'
import { createApolloProvider } from '@vue/apollo-option'
export default ({ app }, inject) => {
// HTTP connection to the API
const httpLink = createHttpLink({
// You should use an absolute URL here
uri: `${app.$config.frontUrl}/graphql`
})
// Cache implementation
const cache = new InMemoryCache()
// Create the apollo client
const apolloClient = new ApolloClient({
link: httpLink,
cache,
$query: {
loadingKey: 'loading', // The key to store the loading state in the Apollo cache
fetchPolicy: 'cache-and-network' // The fetch policy for the query
}
})
const apolloProvider = createApolloProvider({
defaultClient: apolloClient
})
inject('apolloProvider', apolloProvider)
} It would be great if one of you can provide some help please 🙏 |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
I was able to get @vue/apollo-option working in a Vue 2.7 app, but there were a few issues that I had to work around:
app.use(apolloProvider)
style installation process used by @vue/apollo-option and Vue 3. That said, I was able to successfully install it and get around errors with this kind of installation:Describe the solution you'd like
It would be great if @vue/apollo-options would be updated to officially support Vue 2.7 without needing to do any workarounds. Even with the current workarounds, there are no guarantees that further versions of the package will work with Vue 2.7, so official support would give us that guarantee.
Describe alternatives you've considered
See my workarounds above
Beta Was this translation helpful? Give feedback.
All reactions