diff --git a/.changeset/eight-mirrors-sing.md b/.changeset/eight-mirrors-sing.md new file mode 100644 index 0000000000..99095cc7af --- /dev/null +++ b/.changeset/eight-mirrors-sing.md @@ -0,0 +1,5 @@ +--- +'@urql/vue': patch +--- + +Fix regression causing `pause` argument on `useQuery` and `useSubscription` to not be reactive diff --git a/packages/vue-urql/src/useQuery.ts b/packages/vue-urql/src/useQuery.ts index 8d1f5faa2b..59a333c0dd 100644 --- a/packages/vue-urql/src/useQuery.ts +++ b/packages/vue-urql/src/useQuery.ts @@ -1,6 +1,7 @@ /* eslint-disable react-hooks/rules-of-hooks */ import type { WatchStopHandle, Ref } from 'vue'; +import { isRef } from 'vue'; import { shallowRef, ref, watchEffect, reactive } from 'vue'; import type { Subscription, Source } from 'wonka'; @@ -253,7 +254,9 @@ export function callUseQuery( const operation: Ref | undefined> = ref(); const extensions: Ref | undefined> = ref(); - const isPaused = ref(!!unref(args.pause)); + const isPaused: Ref = isRef(_args.pause) + ? _args.pause + : ref(!!_args.pause); const input = shallowRef({ request: createRequest(unref(args.query), unref(args.variables) as V), diff --git a/packages/vue-urql/src/useSubscription.ts b/packages/vue-urql/src/useSubscription.ts index e73710b413..5c24755bd9 100644 --- a/packages/vue-urql/src/useSubscription.ts +++ b/packages/vue-urql/src/useSubscription.ts @@ -4,6 +4,7 @@ import type { Source } from 'wonka'; import { pipe, subscribe, onEnd } from 'wonka'; import type { WatchStopHandle, Ref } from 'vue'; +import { isRef } from 'vue'; import { ref, shallowRef, watchEffect, reactive } from 'vue'; import type { @@ -253,7 +254,9 @@ export function callUseSubscription< const extensions: Ref | undefined> = ref(); const scanHandler = ref(handler); - const isPaused = ref(!!unref(args.pause)); + const isPaused: Ref = isRef(_args.pause) + ? _args.pause + : ref(!!_args.pause); const input = shallowRef({ request: createRequest(unref(args.query), unref(args.variables) as V),