Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vue): Fix regression causing pause argument to not be reactive #3595

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eight-mirrors-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@urql/vue': patch
---

Fix regression causing `pause` argument on `useQuery` and `useSubscription` to not be reactive
5 changes: 4 additions & 1 deletion packages/vue-urql/src/useQuery.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -253,7 +254,9 @@ export function callUseQuery<T = any, V extends AnyVariables = AnyVariables>(
const operation: Ref<Operation<T, V> | undefined> = ref();
const extensions: Ref<Record<string, any> | undefined> = ref();

const isPaused = ref(!!unref(args.pause));
const isPaused: Ref<boolean> = isRef(_args.pause)
? _args.pause
: ref(!!_args.pause);

const input = shallowRef({
request: createRequest<T, V>(unref(args.query), unref(args.variables) as V),
Expand Down
5 changes: 4 additions & 1 deletion packages/vue-urql/src/useSubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -253,7 +254,9 @@ export function callUseSubscription<
const extensions: Ref<Record<string, any> | undefined> = ref();

const scanHandler = ref(handler);
const isPaused = ref(!!unref(args.pause));
const isPaused: Ref<boolean> = isRef(_args.pause)
? _args.pause
: ref(!!_args.pause);

const input = shallowRef({
request: createRequest<T, V>(unref(args.query), unref(args.variables) as V),
Expand Down