@@ -19,11 +19,13 @@ import type {
1919 ApolloQueryResult ,
2020 SubscribeToMoreOptions ,
2121 FetchMoreQueryOptions ,
22- FetchMoreOptions ,
2322 ObservableSubscription ,
2423 TypedDocumentNode ,
2524 ApolloError ,
2625 ApolloClient ,
26+ UpdateQueryMapFn ,
27+ Unmasked ,
28+ MaybeMasked ,
2729} from '@apollo/client/core/index.js'
2830import { throttle , debounce } from 'throttle-debounce'
2931import { useApolloClient } from './useApolloClient'
@@ -81,9 +83,14 @@ export interface UseQueryReturn<TResult, TVariables extends OperationVariables>
8183 options : UseQueryOptions < TResult , TVariables > | Ref < UseQueryOptions < TResult , TVariables > >
8284 query : Ref < ObservableQuery < TResult , TVariables > | null | undefined >
8385 refetch : ( variables ?: TVariables ) => Promise < ApolloQueryResult < TResult > > | undefined
84- fetchMore : ( options : FetchMoreQueryOptions < TVariables , TResult > & FetchMoreOptions < TResult , TVariables > ) => Promise < ApolloQueryResult < TResult > > | undefined
85- updateQuery : ( mapFn : ( previousQueryResult : TResult , options : Pick < WatchQueryOptions < TVariables , TResult > , 'variables' > ) => TResult ) => void
86- subscribeToMore : < TSubscriptionVariables = OperationVariables , TSubscriptionData = TResult > ( options : SubscribeToMoreOptions < TResult , TSubscriptionVariables , TSubscriptionData > | Ref < SubscribeToMoreOptions < TResult , TSubscriptionVariables , TSubscriptionData > > | ReactiveFunction < SubscribeToMoreOptions < TResult , TSubscriptionVariables , TSubscriptionData > > ) => void
86+ fetchMore : < TFetchData = TResult , TFetchVars extends OperationVariables = TVariables > ( options : FetchMoreQueryOptions < TFetchVars , TFetchData > & {
87+ updateQuery ?: ( previousQueryResult : Unmasked < TResult > , options : {
88+ fetchMoreResult : Unmasked < TFetchData >
89+ variables : TFetchVars
90+ } ) => Unmasked < TResult >
91+ } ) => Promise < ApolloQueryResult < MaybeMasked < TFetchData > > > | undefined
92+ updateQuery : ( mapFn : UpdateQueryMapFn < TResult , TVariables > ) => void
93+ subscribeToMore : < TSubscriptionVariables extends OperationVariables = OperationVariables , TSubscriptionData = TResult > ( options : SubscribeToMoreOptions < TResult , TSubscriptionVariables , TSubscriptionData > | Ref < SubscribeToMoreOptions < TResult , TSubscriptionVariables , TSubscriptionData > > | ReactiveFunction < SubscribeToMoreOptions < TResult , TSubscriptionVariables , TSubscriptionData > > ) => void
8794 onResult : ( fn : ( param : ApolloQueryResult < TResult > , context : OnResultContext ) => void ) => {
8895 off : ( ) => void
8996 }
@@ -545,15 +552,20 @@ export function useQueryImpl<
545552
546553 // Update Query
547554
548- function updateQuery ( mapFn : ( previousQueryResult : TResult , options : Pick < WatchQueryOptions < TVariables , TResult > , 'variables' > ) => TResult ) {
555+ function updateQuery ( mapFn : UpdateQueryMapFn < TResult , TVariables > ) {
549556 if ( query . value ) {
550557 query . value . updateQuery ( mapFn )
551558 }
552559 }
553560
554561 // Fetch more
555562
556- function fetchMore ( options : FetchMoreQueryOptions < TVariables , TResult > & FetchMoreOptions < TResult , TVariables > ) {
563+ function fetchMore < TFetchData = TResult , TFetchVars extends OperationVariables = TVariables > ( options : FetchMoreQueryOptions < TFetchVars , TFetchData > & {
564+ updateQuery ?: ( previousQueryResult : Unmasked < TResult > , options : {
565+ fetchMoreResult : Unmasked < TFetchData >
566+ variables : TFetchVars
567+ } ) => Unmasked < TResult >
568+ } ) : Promise < ApolloQueryResult < MaybeMasked < TFetchData > > > | undefined {
557569 if ( query . value ) {
558570 error . value = null
559571 loading . value = true
@@ -571,7 +583,7 @@ export function useQueryImpl<
571583 const subscribeToMoreItems : SubscribeToMoreItem [ ] = [ ]
572584
573585 function subscribeToMore <
574- TSubscriptionVariables = OperationVariables ,
586+ TSubscriptionVariables extends OperationVariables = OperationVariables ,
575587 TSubscriptionData = TResult
576588 > (
577589 options : SubscribeToMoreOptions < TResult , TSubscriptionVariables , TSubscriptionData > |
0 commit comments