How to provide $apollo for Nuxt 2 Bridge composition API?

601 Views Asked by At

There's an open issue with some examples of using @vue/apollo-composable but they don't work with Nuxt 2 Bridge.

1

There are 1 best solutions below

0
On

plugins/provide-apollo-client.ts

import { provideApolloClient } from '@vue/apollo-composable'

export default defineNuxtPlugin((nuxtApp) => {
  provideApolloClient(nuxtApp.apolloProvider?.defaultClient)
})

Component.vue


<script setup lang="ts">

const { $apollo } = useNuxtApp()

</script>