Skip to content

Commit

Permalink
fix: useQuery loading and debounce issues (#1313)
Browse files Browse the repository at this point in the history
fix #1235
fix #1271
  • Loading branch information
neil585456525 committed May 3, 2022
1 parent 34ed387 commit 082acf9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/vue-apollo-composable/src/useQuery.ts
@@ -1,6 +1,7 @@
import {
ref,
Ref,
unref,
isRef,
computed,
watch,
Expand Down Expand Up @@ -360,7 +361,7 @@ export function useQueryImpl<
function updateRestartFn () {
// On server, will be called before currentOptions is initialized
// @TODO investigate
if (!currentOptions) {
if (!currentOptions.value) {
debouncedRestart = baseRestart
} else {
if (currentOptions.value?.throttle) {
Expand Down Expand Up @@ -404,7 +405,7 @@ export function useQueryImpl<
})

// Applying options
watch(() => isRef(optionsRef) ? optionsRef.value : optionsRef, value => {
watch(() => unref(optionsRef), value => {
if (currentOptions.value && (
currentOptions.value.throttle !== value.throttle ||
currentOptions.value.debounce !== value.debounce
Expand All @@ -418,14 +419,15 @@ export function useQueryImpl<
immediate: true,
})

// Fefetch
// Refetch

function refetch (variables: TVariables | undefined = undefined) {
if (query.value) {
if (variables) {
currentVariables = variables
}
error.value = null
loading.value = true
return query.value.refetch(variables)
}
}
Expand Down

0 comments on commit 082acf9

Please sign in to comment.