I'm currently working on integrating Vue Apollo into a Vite project using the composition API. Here is how my main.js file looks:
import { createApp } from 'vue'
import App from './App.vue'
import * as apolloProvider from '../apollo.provider'
import router from './router'
const app = createApp(App)
app
.use(router)
.use(apolloProvider.provider)
.mount('#app')
In the vue4 setup section, it is recommended to update the main.js like this:
import { createApp, provide, h } from 'vue'
import { DefaultApolloClient } from '@vue/apollo-composable'
const app = createApp({
setup () {
provide(DefaultApolloClient, apolloClient)
},
render: () => h(App),
})
I am encountering difficulties in integrating this code into my main.js. Every time I import DefaultApolloClient, my application gets stuck in a loop of refreshing itself. Any suggestions on how to resolve this issue?
p.s. Here is the content of my packages.json:
{
"name": "kiddo-vite-frontend",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@vue/apollo-composable": "^4.0.0-alpha.17",
"apollo-boost": "^0.4.9",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link": "^1.2.14",
"apollo-link-context": "^1.0.20",
"apollo-link-http": "^1.5.17",
"graphql": "^16.5.0",
"graphql-tag": "^2.12.6",
"vue": "^3.2.30",
"vue-apollo": "^3.1.0",
"vue-router": "^4.0.15"
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.3",
"vite": "^2.9.9"
}
}
Thank you.
Valerio