-
-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use hasInjectionContext in useApolloClient before calling inject
- Loading branch information
Dawid Kopys
committed
Jan 17, 2024
1 parent
c795f25
commit a5eb3a0
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