Skip to content

Commit 082acf9

Browse files
fix: useQuery loading and debounce issues (#1313)
fix #1235 fix #1271
1 parent 34ed387 commit 082acf9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/vue-apollo-composable/src/useQuery.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
ref,
33
Ref,
4+
unref,
45
isRef,
56
computed,
67
watch,
@@ -360,7 +361,7 @@ export function useQueryImpl<
360361
function updateRestartFn () {
361362
// On server, will be called before currentOptions is initialized
362363
// @TODO investigate
363-
if (!currentOptions) {
364+
if (!currentOptions.value) {
364365
debouncedRestart = baseRestart
365366
} else {
366367
if (currentOptions.value?.throttle) {
@@ -404,7 +405,7 @@ export function useQueryImpl<
404405
})
405406

406407
// Applying options
407-
watch(() => isRef(optionsRef) ? optionsRef.value : optionsRef, value => {
408+
watch(() => unref(optionsRef), value => {
408409
if (currentOptions.value && (
409410
currentOptions.value.throttle !== value.throttle ||
410411
currentOptions.value.debounce !== value.debounce
@@ -418,14 +419,15 @@ export function useQueryImpl<
418419
immediate: true,
419420
})
420421

421-
// Fefetch
422+
// Refetch
422423

423424
function refetch (variables: TVariables | undefined = undefined) {
424425
if (query.value) {
425426
if (variables) {
426427
currentVariables = variables
427428
}
428429
error.value = null
430+
loading.value = true
429431
return query.value.refetch(variables)
430432
}
431433
}

0 commit comments

Comments
 (0)