import type { InnerClientState } from '../Client/client' ; import type { InlineResolveOptions , Resolvers } from '../Client/resolvers' ; export function isFunction < T > ( v ) { return typeof v === 'function' ; } export interface Refetch { < T = void | undefined > ( refetchArg ) : Promise < T > ; } export function createRefetch ( innerState , resolveSelections , inlineResolved ) { const { accessorCache } = innerState ; const inlineResolveRefetch = { refetch : true , } ; async function refetch < T = undefined | void > ( refetchArg ) { if ( isFunction ( refetchArg ) ) return inlineResolved ( refetchArg , inlineResolveRefetch ) ; if ( accessorCache . isProxy ( refetchArg ) ) { const selectionSet = accessorCache . getSelectionSetHistory ( refetchArg ) ; if ( selectionSet ) { await resolveSelections ( selectionSet , undefined , { ignoreResolveCache : true , } ) ; } return refetchArg ; } if ( process . env . NODE_ENV !== 'production' ) { console . warn ( 'gqty: Invalid proxy to refetch!' , refetchArg ) ; } return refetchArg ; } return refetch ; }