fix: use shallowRef on result & error
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { DocumentNode } from 'graphql'
|
import { DocumentNode } from 'graphql'
|
||||||
import { MutationOptions, OperationVariables, FetchResult, TypedDocumentNode, ApolloError, ApolloClient } from '@apollo/client/core/index.js'
|
import { MutationOptions, OperationVariables, FetchResult, TypedDocumentNode, ApolloError, ApolloClient } from '@apollo/client/core/index.js'
|
||||||
import { ref, onBeforeUnmount, isRef, Ref, getCurrentInstance } from 'vue-demi'
|
import { ref, onBeforeUnmount, isRef, Ref, getCurrentInstance, shallowRef } from 'vue-demi'
|
||||||
import { useApolloClient } from './useApolloClient'
|
import { useApolloClient } from './useApolloClient'
|
||||||
import { ReactiveFunction } from './util/ReactiveFunction'
|
import { ReactiveFunction } from './util/ReactiveFunction'
|
||||||
import { useEventHook } from './util/useEventHook'
|
import { useEventHook } from './util/useEventHook'
|
||||||
@@ -56,7 +56,7 @@ export function useMutation<
|
|||||||
const vm = getCurrentInstance()
|
const vm = getCurrentInstance()
|
||||||
const loading = ref<boolean>(false)
|
const loading = ref<boolean>(false)
|
||||||
vm && trackMutation(loading)
|
vm && trackMutation(loading)
|
||||||
const error = ref<ApolloError | null>(null)
|
const error = shallowRef<ApolloError | null>(null)
|
||||||
const called = ref<boolean>(false)
|
const called = ref<boolean>(false)
|
||||||
|
|
||||||
const doneEvent = useEventHook<[FetchResult<TResult, Record<string, any>, Record<string, any>>, OnDoneContext]>()
|
const doneEvent = useEventHook<[FetchResult<TResult, Record<string, any>, Record<string, any>>, OnDoneContext]>()
|
||||||
|
|||||||
@@ -165,9 +165,9 @@ export function useQueryImpl<
|
|||||||
/**
|
/**
|
||||||
* Result from the query
|
* Result from the query
|
||||||
*/
|
*/
|
||||||
const result = ref<TResult | undefined>()
|
const result = shallowRef<TResult | undefined>()
|
||||||
const resultEvent = useEventHook<[ApolloQueryResult<TResult>, OnResultContext]>()
|
const resultEvent = useEventHook<[ApolloQueryResult<TResult>, OnResultContext]>()
|
||||||
const error = ref<ApolloError | null>(null)
|
const error = shallowRef<ApolloError | null>(null)
|
||||||
const errorEvent = useEventHook<[ApolloError, OnErrorContext]>()
|
const errorEvent = useEventHook<[ApolloError, OnErrorContext]>()
|
||||||
|
|
||||||
// Loading
|
// Loading
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
getCurrentInstance,
|
getCurrentInstance,
|
||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
nextTick,
|
nextTick,
|
||||||
|
shallowRef,
|
||||||
} from 'vue-demi'
|
} from 'vue-demi'
|
||||||
import type {
|
import type {
|
||||||
OperationVariables,
|
OperationVariables,
|
||||||
@@ -127,9 +128,9 @@ export function useSubscription <
|
|||||||
const variablesRef = paramToRef(variables)
|
const variablesRef = paramToRef(variables)
|
||||||
const optionsRef = paramToReactive(options)
|
const optionsRef = paramToReactive(options)
|
||||||
|
|
||||||
const result = ref<TResult | null | undefined>()
|
const result = shallowRef<TResult | null | undefined>()
|
||||||
const resultEvent = useEventHook<[FetchResult<TResult>, OnResultContext]>()
|
const resultEvent = useEventHook<[FetchResult<TResult>, OnResultContext]>()
|
||||||
const error = ref<ApolloError | null>(null)
|
const error = shallowRef<ApolloError | null>(null)
|
||||||
const errorEvent = useEventHook<[ApolloError, OnErrorContext]>()
|
const errorEvent = useEventHook<[ApolloError, OnErrorContext]>()
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|||||||
Reference in New Issue
Block a user