-
-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use hasInjectionContext in useApolloClient before calling inject (…
…#1529) Co-authored-by: Dawid Kopys <[email protected]>
- Loading branch information
1 parent
c795f25
commit 460a0db
Showing
4 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
packages/test-e2e-composable-vue3/src/components/NoSetupScopeQuery.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script lang="ts"> | ||
import { apolloClient } from '@/apollo' | ||
import gql from 'graphql-tag' | ||
import { provideApolloClient, useQuery } from '@vue/apollo-composable' | ||
import { ref, defineComponent, hasInjectionContext, effectScope, computed, watch, onBeforeUnmount } from 'vue' | ||
const hello = ref('') | ||
const scope = effectScope() | ||
scope.run(() => { | ||
const query = provideApolloClient(apolloClient)(() => useQuery(gql` | ||
query hello { | ||
hello | ||
} | ||
`)) | ||
const innerHello = computed(() => query.result.value?.hello ?? '') | ||
watch(innerHello, (newHello) => { | ||
hello.value = newHello | ||
}, { | ||
immediate: true, | ||
}) | ||
}) | ||
export default defineComponent({ | ||
setup () { | ||
onBeforeUnmount(() => { | ||
scope.stop() | ||
}) | ||
return { | ||
hello, | ||
} | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="no-setup-scope-query"> | ||
{{ hello }} | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters