Open
Description
Describe the bug
Using useQuery
and attempting to enable a disabled query when used outside of setup()
. Looks like the ApolloClient is coming back as null
.
vue.runtime.esm.js:619 [Vue warn]: Error in callback for watcher "function () { return source.value; }": "Error: Apollo client with id default not found. Use provideApolloClient() if you are outside of a component setup."
Error: Apollo client with id default not found. Use provideApolloClient() if you are outside of a component setup.
Logging out the following in useApolloClient
...
To Reproduce
Steps to reproduce the behavior:
- Clone this v4 repo
- Go to
/packages/test-e2e-composable-vue3/src/components/NoSetupQuery.vue
- Update the
<script>
tag with what you see below - Try running your
no-setup-query
test.
<script lang="ts">
import { apolloClient } from '@/apollo'
import { gql } from '@apollo/client/core'
import { provideApolloClient, useQuery, useResult } from '@vue/apollo-composable'
import { defineComponent, ref } from 'vue'
// Global query
const enabled = ref(false)
const query = provideApolloClient(apolloClient)(() => useQuery(gql`
query hello {
hello
}
`, null, () => ({ enabled: enabled.value })))
const hello = useResult(query.result, [])
function enable () {
enabled.value = true
}
export default defineComponent({
setup () {
enable()
return {
hello,
}
},
})
</script>
Expected behavior
I expect the default ApolloClient, provided using provideApolloClient()
, to be found by useQuery()
and and for the query to execute once enabled.
Versions
vue: 2.6 w/ @vue/composition-api
plugin
vue-apollo: 4.0.0-alpha.12
apollo-client: 3.2.2
Metadata
Metadata
Assignees
Labels
No labels