From 2de65e4822c4f5ceabba703c12451595e2deea20 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Tue, 16 May 2023 15:05:39 +0200 Subject: [PATCH] fix: initialize currentDocument early, fix #1325 --- packages/vue-apollo-composable/src/useQuery.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/vue-apollo-composable/src/useQuery.ts b/packages/vue-apollo-composable/src/useQuery.ts index 504fe36..f6807c2 100644 --- a/packages/vue-apollo-composable/src/useQuery.ts +++ b/packages/vue-apollo-composable/src/useQuery.ts @@ -204,7 +204,8 @@ export function useQueryImpl< function start () { if ( started || !isEnabled.value || - (isServer && currentOptions.value?.prefetch === false) + (isServer && currentOptions.value?.prefetch === false) || + !currentDocument ) { if (firstResolve) firstResolve() return @@ -413,6 +414,9 @@ export function useQueryImpl< debouncedRestart() } + // Applying document + let currentDocument: DocumentNode = documentRef.value + // Enabled state const forceDisabled = ref(lazy) @@ -435,12 +439,9 @@ export function useQueryImpl< }) // Applying document - let currentDocument: DocumentNode watch(documentRef, value => { currentDocument = value restart() - }, { - immediate: true, }) // Applying variables