graphql apollo - Cannot redefine property $apollo

iam create plugins but error
No description
1 Reply
productdevbook
productdevbookOP2y ago
import {
ApolloClient,
InMemoryCache,
createHttpLink,
} from '@apollo/client/core'
import {
DefaultApolloClient,
provideApolloClient,
} from '@vue/apollo-composable'
import { defineNuxtPlugin } from '#app'

export default defineNuxtPlugin((nuxtApp) => {
const httpLink = createHttpLink({
credentials: 'omit',
uri: 'http://127.0.0.1:4000/graphql',

})

const cache = new InMemoryCache()

let apolloClient: ApolloClient<any>

if (process.server) {
apolloClient = new ApolloClient({
ssrMode: true,
link: httpLink,
cache,
})
nuxtApp.hook('app:rendered', () => {
nuxtApp.payload.data.apollo = apolloClient.extract()
})
}
else {
apolloClient = new ApolloClient({
link: httpLink,
cache,
ssrForceFetchDelay: 100,
})
}

provideApolloClient(apolloClient)
nuxtApp.provide('apollo', { DefaultApolloClient, apolloClient })
})
import {
ApolloClient,
InMemoryCache,
createHttpLink,
} from '@apollo/client/core'
import {
DefaultApolloClient,
provideApolloClient,
} from '@vue/apollo-composable'
import { defineNuxtPlugin } from '#app'

export default defineNuxtPlugin((nuxtApp) => {
const httpLink = createHttpLink({
credentials: 'omit',
uri: 'http://127.0.0.1:4000/graphql',

})

const cache = new InMemoryCache()

let apolloClient: ApolloClient<any>

if (process.server) {
apolloClient = new ApolloClient({
ssrMode: true,
link: httpLink,
cache,
})
nuxtApp.hook('app:rendered', () => {
nuxtApp.payload.data.apollo = apolloClient.extract()
})
}
else {
apolloClient = new ApolloClient({
link: httpLink,
cache,
ssrForceFetchDelay: 100,
})
}

provideApolloClient(apolloClient)
nuxtApp.provide('apollo', { DefaultApolloClient, apolloClient })
})
Want results from more Discord servers?
Add your server