Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.

perf(vue): use shallowRef for data (#3641)

Changed files
+11 -6
.changeset
packages
+5
.changeset/old-humans-knock.md
···
+
---
+
'@urql/vue': patch
+
---
+
+
Use `shallowRef` for data variable to avoid extra overhead for heavy objects
+2 -2
packages/vue-urql/src/useMutation.ts
···
/* eslint-disable react-hooks/rules-of-hooks */
import type { Ref } from 'vue';
-
import { ref } from 'vue';
+
import { shallowRef } from 'vue';
import { pipe, onPush, filter, toPromise, take } from 'wonka';
import type {
···
query: MaybeRef<DocumentInput<T, V>>,
client: Ref<Client> = useClient()
): UseMutationResponse<T, V> {
-
const data: Ref<T | undefined> = ref();
+
const data: Ref<T | undefined> = shallowRef();
const { fetching, operation, extensions, stale, error } = useRequestState<
T,
+2 -2
packages/vue-urql/src/useQuery.ts
···
/* eslint-disable react-hooks/rules-of-hooks */
import type { Ref, WatchStopHandle } from 'vue';
-
import { ref, watchEffect } from 'vue';
+
import { shallowRef, watchEffect } from 'vue';
import type { Subscription } from 'wonka';
import { pipe, subscribe, onEnd } from 'wonka';
···
client: Ref<Client> = useClient(),
stops?: WatchStopHandle[]
): UseQueryResponse<T, V> {
-
const data: Ref<T | undefined> = ref();
+
const data: Ref<T | undefined> = shallowRef();
const { fetching, operation, extensions, stale, error } = useRequestState<
T,
+2 -2
packages/vue-urql/src/useSubscription.ts
···
import { pipe, subscribe, onEnd } from 'wonka';
import type { Ref, WatchStopHandle } from 'vue';
-
import { isRef, ref, watchEffect } from 'vue';
+
import { shallowRef, isRef, watchEffect } from 'vue';
import type {
Client,
···
client: Ref<Client> = useClient(),
stops?: WatchStopHandle[]
): UseSubscriptionResponse<T, R, V> {
-
const data: Ref<R | undefined> = ref();
+
const data: Ref<R | undefined> = shallowRef();
const { fetching, operation, extensions, stale, error } = useRequestState<
T,